kokkos / mdspan

Reference implementation of mdspan targeting C++23
Other
415 stars 69 forks source link

Error building on macOS 11: expected concept name with optional arguments in layout_stride.hpp #154

Closed stigrs closed 2 years ago

stigrs commented 2 years ago

I tried to build mdspan on macOS 11 using AppleClang 13.0.0.13000029, and got the following errors:

In file included from /Users/runner/work/1/s/build/_deps/mdspan-src/include/experimental/__p0009_bits/layout_right.hpp:50:
/Users/runner/work/1/s/build/_deps/mdspan-src/include/experimental/__p0009_bits/layout_stride.hpp:81:35: error: expected concept name with optional arguments
    { M::is_always_strided() } -> same_as<bool>;
                                  ^
/Users/runner/work/1/s/build/_deps/mdspan-src/include/experimental/__p0009_bits/layout_stride.hpp:82:38: error: expected concept name with optional arguments
    { M::is_always_exhaustive() } -> same_as<bool>;
                                     ^
/Users/runner/work/1/s/build/_deps/mdspan-src/include/experimental/__p0009_bits/layout_stride.hpp:83:34: error: expected concept name with optional arguments
    { M::is_always_unique() } -> same_as<bool>;
                                 ^
mhoemmen commented 2 years ago

@stigrs Thanks for reporting! The concept is protected by #if _MDSPAN_USE_CONCEPTS && MDSPAN_HAS_CXX_20, and Clang 13 supposedly supports concepts, so here are some possibilities.

  1. Clang 13 can't deduce that same_as means std::same_as (even though this all takes place in the scope of namespace std)
  2. <concepts> hasn't been included
  3. Clang 13 actually doesn't support concepts, and the CMake deduction logic for computing MDSPAN_HAS_CXX_20 is wrong

Could you please try replacing same_as with ::std::same_as (note the double colon prefix) in those three lines? If that doesn't work, could you also try including <concepts> at the top of the header file?

crtrott commented 2 years ago

Note I can reproduce this with clang13 on linux

crtrott commented 2 years ago

The breakage on clang13 for me is that by default it was using GCC 9 headers from some gcc install. It still was defining __cpp_concepts but didn't have the include or the concepts available. Telling my clang-13 to use gcc11 header files (or presumably its own stdlib stuff) fixes the issue.

crtrott commented 2 years ago

could reproduce on Mac: including concepts fixes the issue.

crtrott commented 2 years ago

See #155