On 02/09/2023 18:54, Bruno Haible wrote:
Bjarni Ingi Gislason wrote:
While compiling "groff" with gcc (Debian 13.2.0-2) 13.2.0) and "-std=gnu2x":
../lib/openat-die.c: In function 'openat_save_fail':
./lib/error.h:410:8: warning: ISO C forbids braced-groups within expressions
[-Wpedantic]
410 | : ({ \
| ^
./lib/error.h:470:7: note: in expansion of macro '__gl_error_call'
470 | __gl_error_call (error, status, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
../lib/openat-die.c:37:3: note: in expansion of macro 'error'
37 | error (exit_failure, errnum,
| ^~~~~
../lib/openat-die.c: In function 'openat_restore_fail':
./lib/error.h:410:8: warning: ISO C forbids braced-groups within expressions
[-Wpedantic]
410 | : ({ \
| ^
./lib/error.h:470:7: note: in expansion of macro '__gl_error_call'
470 | __gl_error_call (error, status, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
../lib/openat-die.c:56:3: note: in expansion of macro 'error'
56 | error (exit_failure, errnum,
| ^~~~~
The option "-std=gnu2x" is useful; however, the option "-Wpedantic" that you
have enabled is generally much less useful.
This code in lib/error.h exists for the purpose of providing actually
useful warnings about the control flow, such as when a 'break;' statement
in a switch statement has been forgotten. We will not revert or change
this code, just for "-Wpedantic".
GNU extensions like ({...}) have their purpose, and we use them because
they are useful here.
You asked for -Wpedantic warnings; you obtained them.
A recent gotcha I've noticed with -Wpedantic is that it may be ignored.
I.e. testing on gcc 13, and ever since commit:
https://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=4f6131a786
if the user specifies --Wpedantic, then it's ignored
(and that's not at all obvious as there are early warnings before the pragma).
I was trying to use -Wpedantic to check for standards conformance,
where some code compilable on gcc 13 by default, is no longer compilable on gcc
<= 10.
A workaround for me for now is to use more specific gcc language conformance
flags,
and filter to non gnulib code, like:
$ make CFLAGS='-O2 -Wc99-c11-compat -Wc11-c2x-compat -Wno-error' 2>&1 |
grep 'src/.*warning:' | grep -Ev '_Noreturn|_Static_assert'
src/tail.c:2211:13: warning: a label can only be part of a statement \
and a declaration is not a statement [-Wc11-c2x-compat]
cheers,
Pádraig