Skip to content

STDEXEC_HAS_FEATURE(__cpp_lib_execution) fails with recent libstdc++. #1523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jehelset opened this issue May 1, 2025 · 1 comment
Open

Comments

@jehelset
Copy link
Contributor

jehelset commented May 1, 2025

I think 0242ad9 broke NVIDIA/stdexec for at least gcc-15 and gcc-trunk (https://godbolt.org/z/9ez66G7vv).

it checks __has_feature(__cpp_lib_execution), but in libstdc++ is a macro defined at https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/bits/version.h#L672.

should perhaps guard with

#if defined(__cpp_lib_execution)
#  define STDEXEC_HAS_EXECUTION_POLICY() 0
#elif __has_feature(__cpp_lib_execution)
#  define STDEXEC_HAS_EXECUTION_POLICY() 1
#else
#  define STDEXEC_HAS_EXECUTION_POLICY() 0
#endif

@lucteo

@prlw1
Copy link

prlw1 commented May 6, 2025

As it stands, I think the logic in the above is backwards and the first 0 should be a 1, and the resulting build failure is a separate bug.

However, this is on the right lines. A little digging in case it helps:

STDEXEC_HAS_FEATURE is used twice in stdexec: 1) to detect thread_sanitizer, and 2) to detect __cpp_lib_execution.

In 1), that is precisely to detect a compiler feature. In 2), it is used to check whether the compiler has implemented a C++ library feature.
The use in 2) was standardised in c++20 with the advent of the <version> header, in P0754R2.

Using STDEXEC_HAS_FEATURE for case 2) has been replaced by including <version> and testing for __cpp_lib... macros directly.

The nit is that execution policies first arrived in c++17, so predates this checking system. On the other hand, I think both execution and version landed in gcc 9, so I think testing for __cpp_lib_execution should work no matter what.

I don't know the clang situation, and the 1) use has to remain, as I think it is clang specific, and gcc's compatibility __has_feature is intended to work with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants