https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115740
Bug ID: 115740
Summary: gcc-14.1.1: __glibcxx_assert_fail const-evaluation
breaks clang/hip device code
Product: gcc
Version: 14.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: lockalsash at gmail dot com
Target Milestone: ---
After introducing of call to std::__glibcxx_assert_fail() in
_GLIBCXX_HAVE_IS_CONSTANT_EVALUATED ifdef block, clang fails to compile some
code (found on pytorch)
gcc version 14.1.1 20240622 (Gentoo Hardened 14.1.1_p20240622 p2)
Breaking change:
https://github.com/gcc-mirror/gcc/commit/1395c573c523762957bde8c2a08832c5f4350815
-------------------------------------------------------------------
Error message:
In file included from <built-in>:1:
In file included from
/usr/lib/llvm/18/bin/../../../../lib/clang/18/include/__clang_hip_runtime_wrapper.h:145:
In file included from
/usr/lib/llvm/18/bin/../../../../lib/clang/18/include/cuda_wrappers/algorithm:55:
In file included from
/usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14/algorithm:61:
/usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14/bits/stl_algo.h:3625:7:
error: reference to __host__ function '__glibcxx_assert_fail' in
__host__ __device__ function
3625 | __glibcxx_assert(!(__hi < __lo));
| ^
/usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14/x86_64-pc-linux-gnu/bits/c++config.h:612:7:
note: expanded from macro '__glibcxx_assert'
612 | std::__glibcxx_assert_fail();
\
| ^
/var/tmp/portage/sci-libs/caffe2-2.3.1/work/pytorch-2.3.1/aten/src/ATen/native/hip/IndexKernel.hip:254:21:
note: called by 'operator()'
254 | qvalue = std::clamp(qvalue, qmin, qmax);
| ^
/var/tmp/portage/sci-libs/caffe2-2.3.1/work/pytorch-2.3.1/aten/src/ATen/native/hip/IndexKernel.hip:101:5:
note: called by 'operator()'
101 | f(out_data, in_data, offset);
| ^
/var/tmp/portage/sci-libs/caffe2-2.3.1/work/pytorch-2.3.1/aten/src/ATen/native/hip/IndexKernel.hip:36:7:
note: called by
'index_elementwise_kernel<128, 4, (lambda at
/var/tmp/portage/sci-libs/caffe2-2.3.1/work/pytorch-2.3.1/aten/src/ATen/native/hip/IndexKernel.hip:85:62)>'
36 | f(idx);
| ^
/usr/lib/gcc/x86_64-pc-linux-gnu/14/include/g++-v14/x86_64-pc-linux-gnu/bits/c++config.h:605:3:
note: '__glibcxx_assert_fail' declared here
605 | __glibcxx_assert_fail()
| ^
-------------------------------------------------------------------
How it can be fixed: by adding constexpr:
__attribute__((__always_inline__,__visibility__("default")))
_GLIBCXX_CONSTEXPR inline void
__glibcxx_assert_fail()
{ }
-------------------------------------------------------------------
Why it exists in the first place: I don't know. c++config.h calls empty
function for some reason (maybe for setting debugger breakpoints?).