[PATCH] assert: Support assert as variadic macro for C++26 [PR27276]
Tomasz Kaminski
tkaminsk@redhat.com
Wed Feb 18 16:27:05 GMT 2026
On Wed, Feb 18, 2026 at 12:58 PM Adhemerval Zanella Netto <
adhemerval.zanella@linaro.org> wrote:
>
>
> On 18/02/26 06:28, Jonathan Wakely wrote:
> > On Tue, 17 Feb 2026 at 19:03, Paul Eggert <eggert@cs.ucla.edu> wrote:
> >>
> >> On 2026-02-17 06:48, Tomasz Kamiński wrote:
> >>
> >>> On Mon, Feb 16, 2026 at 11:04 PM Paul Eggert <eggert@cs.ucla.edu>
> wrote:
> >>>
> >>>>> On 2026-02-09 03:27, Tomasz Kamiński wrote:
> >>>>>
> >>>>>>> Mainly for testing purposes we allow enabling/disabling variadic
> assert
> >>>>>>> regardless of version of C or C++, by defining __ASSERT_VARIADIC to
> >>>>>>> 1/0 respectively before inclusion of <assert>
> >>>>>
> >>>>> I don't see the need for this extra complexity in this patch. People
> who
> >>>>> want to do that sort of testing can do it in other ways. If there is
> a
> >>>>> need, this part of the patch should be separated out into a different
> >>>>> patch.
> >>>>>
> >>> I would really appreciate guidance on how I could test this in other
> ways,
> >>> in a robust manner.
> >>
> >> One possibility is that a test case that wants __ASSERT_VARIADIC can do
> >> "sed 's/\(define __ASSERT_VARIADIC\) [01]/\1 1/' .../assert.h >assert.h"
> >> and then compile the test with "gcc -I.". That's robust enough for a
> >> test. But see below.
> >>
> >>> I was simply considering guarding the content
> >>> test-assert-c++-variadic.cc with appropriate __cplusplus value,
> >>> but this led to de-facto dead-test.
> >>>
> >>> The problem I am facing is that the test would need to be compiled with
> >>> "-std=c++26", but that is not supported by all versions of GCC that
> glibc
> >>> targets. I have looked into how C23 is tested, to see how to
> conditionally
> >>> pass --std=c23 flag, but they seem to rely on defining ISOC23_SOURCES.
> >>
> >> I'm a little lost here. It sounds like you're trying to test the C++26
> >> features of the new <assert.h> even on C++23 platforms. Why bother? Just
> >> test the platform that you have. If it's a "dead-test" that's OK; the
> >> feature isn't supported on that platform and need not be tested.
> >
> > What is a C++26 platform? There are no platforms where the compiler
> > defaults to C++26, and probably won't be for maybe 5 years. So the
> > test would be dead until then, on all platforms. A test that never
> > runs anywhere is not a good test.
> >
> > What's desirable is to enable the test now for platforms where GCC
> > supports -std=c++26 as an option, but if the test adds -std=c++26 to
> > the makefile then it will fail on platforms where GCC is old and
> > _doesn't_ support that option.
>
> We can add a configure check for --std=c++26 and enable the test iff
> the C++ compiler supports it.
>
I am currently exploring that direction, thank you for the suggestion.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20260218/64cb0da8/attachment.htm>
More information about the Libc-alpha
mailing list