aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2023-12-06 17:21:29 +0000
committerJonathan Wakely <jwakely@redhat.com>2023-12-07 20:54:11 +0000
commit1395c573c523762957bde8c2a08832c5f4350815 (patch)
tree971053488c6e6bef1183129fe9db2d96a20fdf99 /gcc
parent9f0f7d802482a8958d6cdc72f1fe0c8549db2182 (diff)
downloadgcc-1395c573c523762957bde8c2a08832c5f4350815.zip
gcc-1395c573c523762957bde8c2a08832c5f4350815.tar.gz
gcc-1395c573c523762957bde8c2a08832c5f4350815.tar.bz2
libstdc++: Fix recent changes to __glibcxx_assert [PR112882]
The changes in r14-6198-g5e8a30d8b8f4d7 were broken, as I used _GLIBCXX17_CONSTEXPR for the 'if _GLIBCXX17_CONSTEXPR (true)' condition, forgetting that it would also be used for the is_constant_evaluated() check. Using 'if constexpr (std::is_constant_evaluated())' is a bug. Additionally, relying on __glibcxx_assert_fail to give a "not a constant expression" error is a problem because at -O0 an undefined reference to __glibcxx_assert_fail is present in the compiled code. This means you can't use libstdc++ headers without also linking to libstdc++ for the symbol definition. This fix rewrites the __glibcxx_assert macro again. This still avoids doing the duplicate checks, once for constexpr and once at runtime (if _GLIBCXX_ASSERTIONS is defined). When _GLIBCXX_ASSERTIONS is defined we still rely on __glibcxx_assert_fail to give a "not a constant expression" error during constant evaluation (because when assertions are defined it's not a problem to emit a reference to the symbol). But when that macro is not defined, we use a new inline (but not constexpr) overload of __glibcxx_assert_fail to cause compilation to fail. That inline function doesn't cause an undefined reference to a symbol in the library (and will be optimized away anyway). We can also add always_inline to the __is_constant_evaluated function, although this doesn't actually matter for -O0 and it's always inlined with any optimization enabled. libstdc++-v3/ChangeLog: PR libstdc++/112882 * include/bits/c++config (__is_constant_evaluated): Add always_inline attribute. (_GLIBCXX_DO_ASSERT): Remove macro. (__glibcxx_assert): Define separately for assertions-enabled and constexpr-only cases.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions