aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2026-02-25 15:01:23 +0100
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2026-03-02 14:24:17 -0300
commitea37298b65bd67f94c3c2640e91ec5865a5019ad (patch)
treec607f70d73fcca1fb5b8f17b4c5578ff6932862a /sysdeps/unix/sysv
parent44ce02b6a8b0061edf0a312368f2f3fa719c1df8 (diff)
downloadglibc-master.zip
glibc-master.tar.gz
glibc-master.tar.bz2
assert: Support assert as variadic macro for C++26 [PR27276]HEADmaster
C++26 changes assert into a variadic macro to support using assignment-expressions that would be interpreted as multiple macro arguments, in particular one containing: * template parameter lists: func<int, float>() * calls to overloaded operator[] that accepts multiple arguments: arr[1, 2] this is C++23 feature, see libstdc++ PR/119855 [1] * lambdas with explicit captures: [x, y] { ... } The new expansion in form: (__VA_ARGS__) ? void (1 ? 1 : bool (__VA_ARGS__)) : __assert_fail (...) Has the following properties: * Use of (__VA_ARGS__) ? ... : ..., requires that __VA_ARGS__ is contextually convertible to bool. This means that enumerators of scoped enumeration are no longer accepted (they are only explicitly convertible). Thus this patch address the glibc PR/27276 [2]. * Nested ternary 1 ? 1 : bool (__VA_ARGS__) guarantees that expression expanded from __VA_ARGS__ is not evaluated twice. This is used instead of unevaluated context (like sizeof...) to support C++ expressions that are not allowed in unevaluated context (lambdas until C++20, co_await, co_yield). * bool (__VA_ARGS__) is ill-formed if __VA_ARGS__ expands to multiple arguments: assert(1, 2) * bool (__VA_ARGS__) also triggers warnings when __VA_ARGS__ expands to x = 1: assert(x = 1) To guarantee that the code snippets from assert/test-assert-c++-variadic.cc, are actually checked for validity, we need to compile this test in C++26 (-std=c++26) mode. To achieve that, this patch compiles the file with test-config-cxxflags-stdcxx26 variable as additional flag, that is set to -std=c++26 if $(TEST_CXX) executable supports that flag, and empty otherwise. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119855 [2] https://sourceware.org/bugzilla/show_bug.cgi?id=27276 Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com> Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'sysdeps/unix/sysv')
0 files changed, 0 insertions, 0 deletions