kokkos / mdspan

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

Compile Issues with ARM bare-metal GCC #280

Closed ehntoo closed 1 year ago

ehntoo commented 1 year ago

There seems to be some bad interaction with the way libstdc++ is configured/compiled for ARM's bare-metal GNU toolchain (https://developer.arm.com/Tools%20and%20Software/GNU%20Toolchain) and this library that results in a compilation failure:

In file included from /opt/compiler-explorer/arm/gcc-arm-none-eabi-11.2-2022.02/arm-none-eabi/include/c++/11.2.1/cctype:42,
                 from /opt/compiler-explorer/arm/gcc-arm-none-eabi-11.2-2022.02/arm-none-eabi/include/c++/11.2.1/bits/localefwd.h:42,
                 from /opt/compiler-explorer/arm/gcc-arm-none-eabi-11.2-2022.02/arm-none-eabi/include/c++/11.2.1/string:43,
                 from /opt/compiler-explorer/arm/gcc-arm-none-eabi-11.2-2022.02/arm-none-eabi/include/c++/11.2.1/stdexcept:39,
                 from /app/raw.githubusercontent.com/kokkos/mdspan/single-header/mdspan.hpp:1871,
                 from <source>:11:
/app/raw.githubusercontent.com/kokkos/mdspan/single-header/mdspan.hpp:2011:27: error: expected identifier before numeric constant
 2011 | template <class _T, class _U, class _Enable = void> struct __compressed_pair {
      |                           ^~
/app/raw.githubusercontent.com/kokkos/mdspan/single-header/mdspan.hpp:2011:27: error: expected '>' before numeric constant
/app/raw.githubusercontent.com/kokkos/mdspan/single-header/mdspan.hpp:2013:29: error: expected unqualified-id before numeric constant
 2013 |   _MDSPAN_NO_UNIQUE_ADDRESS _U __u_val;
      |                             ^~
/app/raw.githubusercontent.com/kokkos/mdspan/single-header/mdspan.hpp:2018:53: error: expected unqualified-id before numeric constant
 2018 |   MDSPAN_FORCE_INLINE_FUNCTION _MDSPAN_CONSTEXPR_14 _U &__second() noexcept { return __u_val; }
      |                                                     ^~
/app/raw.githubusercontent.com/kokkos/mdspan/single-header/mdspan.hpp:2019:42: error: expected unqualified-id before numeric constant
 2019 |   MDSPAN_FORCE_INLINE_FUNCTION constexpr _U const &__second() const noexcept {
      |                           
...

Godbolt reproduction based on the readme example: https://godbolt.org/z/s6qzafWP4

After some experimentation, I found that you can avoid the error by swapping the order of #include <stdexcept> and #include "layout_stride.hpp" in layout_right.hpp so that #include <stdexcept> comes last: https://github.com/kokkos/mdspan/blob/9d0a451e11177cbdeaef035c7914b0aa73ddd1e2/include/experimental/__p0009_bits/layout_right.hpp#L21-L22

I have not been able to determine why this would fix the issue, though.

ehntoo commented 1 year ago

I swear I searched the issue tracker prior to this, but I've now stumbled on https://github.com/kokkos/mdspan/issues/187, which seems to explain the cause.

Closing, sorry for the noise.