Skip to content

Commit 006e98d

Browse files
committed
Workaround for GCC bug for __builtin_is_constant_evaluated when evaluating attribute argument
1 parent c1c4505 commit 006e98d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

libcxx/include/experimental/__simd/vec_ext.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ inline constexpr bool is_abi_tag_v<simd_abi::__vec_ext<_Np>> = _Np > 0 && _Np <=
3737

3838
template <class _Tp, int _Np>
3939
struct __simd_storage<_Tp, simd_abi::__vec_ext<_Np>> {
40-
_Tp __data __attribute__((__vector_size__(std::__bit_ceil((sizeof(_Tp) * _Np)))));
40+
// This doesn't work in GCC if it is directly inside the __vector_size__ attribute because of a call to
41+
// __builtin_is_constant_evaluated. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105233
42+
static constexpr size_t __vector_size = std::__bit_ceil(sizeof(_Tp) * _Np);
43+
44+
_Tp __data __attribute__((__vector_size__(__vector_size)));
4145

4246
_LIBCPP_HIDE_FROM_ABI _Tp __get(size_t __idx) const noexcept {
4347
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx < _Np, "Index is out of bounds");

0 commit comments

Comments
 (0)