[PATCH v7] assert: Support assert as variadic macro for C++26 [PR27276]

Yury Khrustalev yury.khrustalev@arm.com
Tue Mar 3 10:56:00 GMT 2026


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.

Thanks,
Yury



More information about the Libc-alpha mailing list