Skip to content
Draft
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions libcxx/include/__memory/is_sufficiently_aligned.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#include <__config>
#include <__cstddef/size_t.h>
#include <__type_traits/is_constant_evaluated.h>
#include <cstdint>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Expand All @@ -28,10 +27,11 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool is_sufficiently_aligned(_Tp* __ptr) {
# ifdef _LIBCPP_COMPILER_CLANG_BASED
return __builtin_is_aligned(__ptr, _Alignment);
# else
if constexpr (is_constant_evaluated())
if consteval {
return __builtin_constant_p(__builtin_assume_aligned(__ptr, _Alignment) != nullptr);
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer simply not supporting constexpr with GCC here.
It seems better to fail loudly than to give the wrong result.

Copy link
Member Author

Choose a reason for hiding this comment

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

The goal was to determine whether or not it is implementable, and potentially opening a LWG issue before C++26 is shipped.

else
} else {
return reinterpret_cast<uintptr_t>(__ptr) % _Alignment == 0;
}
# endif
}

Expand Down
Loading