[PATCH v7] assert: Support assert as variadic macro for C++26 [PR27276]
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Tue Mar 3 12:39:33 GMT 2026
On 03/03/26 07:56, Yury Khrustalev wrote:
> On Wed, Feb 25, 2026 at 03:01:23PM +0100, Tomasz Kamiński wrote:
>> From: Jonathan Wakely <jwakely@redhat.com>
>
> This patch has a new test that fails to compile with GCC 14.2 (although
> it works with GCC 14.3) and causes make check to fail e.g. on Debian 13.
>
>> ...
>>
>> diff --git a/assert/test-assert-c++-variadic.cc b/assert/test-assert-c++-variadic.cc
>> new file mode 100644
>> index 0000000000..1bb8eeb525
>> --- /dev/null
>>
>> ...
>>
>> +template <typename Ts>
>> +constexpr bool
>> +assert_works ()
>> +{
>> + return requires (Ts ts) {
>> + assert (ts);
>> + };
>> +}
>> +
>> +enum OE { oe };
>> +enum TE : int { te };
>> +enum class SE : int { se };
>> +
>> +static_assert ( assert_works <OE> ());
>> +static_assert ( assert_works <TE> ());
>
> These static asserts fail:
>
> test-assert-c++-variadic.cc:81:35: error: static assertion failed
> 81 | static_assert ( assert_works <OE> ());
> | ~~~~~~~~~~~~~~~~~~^~
> test-assert-c++-variadic.cc:82:35: error: static assertion failed
> 82 | static_assert ( assert_works <TE> ())
>
> Also:
>
> in ‘constexpr’ expansion of ‘assert_works<OE>()’
> error: ‘constexpr’ call flows off the end of the function
>
> Looks like
>
> #if defined __cplusplus && __cplusplus > 202302L
>
> is not enough to check if this test is supported or not. XFAIL will not
> help here because the test doesn't compile which causes make check to
> fail.
It does seems to me this is a compiler bug, I checked with gcc version 14.3.1 20250814
and gcc version 15.2.1 20260112 without issues.
Tomasz, is this a compiler bug or something has changes for gcc 14? If so
I think we might need __GNUC_PREREQ for the test.
More information about the Libc-alpha
mailing list