On Fri, 16 May 2025, Alejandro Colomar wrote:

> Hmmm, I've been trying to find a compromise between readability and
> simplicity, and I think I have something.  I've seen some tests that
> define assert() themselves.  I like assert(3) because it's more
> readable compared to a conditional plus abort(3).
> 
> So, how do you feel about the following change?
> 
>       diff --git i/gcc/testsuite/gcc.dg/countof-stdcountof.c 
> w/gcc/testsuite/gcc.dg/countof-stdcountof.c
>       index a7fe4079c69..2fb0c6306ef 100644
>       --- i/gcc/testsuite/gcc.dg/countof-stdcountof.c
>       +++ w/gcc/testsuite/gcc.dg/countof-stdcountof.c
>       @@ -3,8 +3,7 @@
>        
>        #include <stdcountof.h>
>        
>       -#undef NDEBUG
>       -#include <assert.h>
>       +#define assert(e)  ((e) ? (void) 0 : __builtin_abort ())

Yes, I think that's a reasonable way for a test to do its assertions with 
assert syntax but without depending unnecessarily on libc headers.

-- 
Joseph S. Myers
josmy...@redhat.com

Reply via email to