Skip to content
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

Restrict the use of [[no_unique_address]] to CXX 20 only. #764

Merged
merged 1 commit into from
Jul 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,8 @@ static_assert(_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_14, "mdspan requires C++14 or
# define _MDSPAN_PRESERVE_STANDARD_LAYOUT 1
#endif

// no unique address starts working in NVCC 11.6
#if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS) && \
(!defined(__NVCC__) || ((__CUDACC_VER_MAJOR__ > 11) && (__CUDACC_VER_MINOR__ > 5)))
# if (__has_cpp_attribute(no_unique_address) >= 201803L) && !defined(_MDSPAN_COMPILER_MSVC)
#if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS)
# if MDSPAN_HAS_CXX_20 && (__has_cpp_attribute(no_unique_address) >= 201803L)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the proposed fix! This looks reasonable. Users can always turn off the feature if their compiler doesn't support it. Are you able to test with MDSPAN_HAS_CXX_20?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't that mean you always turn it off for NVCC since nvcc does not support C++20?

# define _MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS 1
# define _MDSPAN_NO_UNIQUE_ADDRESS [[no_unique_address]]
# else
Expand Down