On 26/05/2023 18:34, Bruno Haible wrote:
In GNU gettext, I see these compilation warnings with gcc 13.1.0:

gcc ... -Wall -Wno-cast-qual -Wno-conversion -Wno-float-equal -Wno-sign-compare 
-Wno-undef -Wno-unused-function -Wno-unused-parameter -Wno-float-conversion 
-Wimplicit-fallthrough -Wno-pedantic -Wno-sign-conversion -Wno-type-limits 
-Wno-unsuffixed-float-constants -g -O2 -c copy-file.c  -fPIC -DPIC -o 
.libs/libgettextlib_la-copy-file.o
copy-file.c: In function 'copy_file_preserving':
copy-file.c:192:7: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
   192 |       error (EXIT_FAILURE, errno, _("error while opening %s for 
reading"),
       |       
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   193 |              quote (src_filename));
       |              ~~~~~~~~~~~~~~~~~~~~~
copy-file.c:195:5: note: here
   195 |     case GL_COPY_ERR_OPEN_BACKUP_WRITE:
       |     ^~~~
and so on.


The option -Wimplicit-fallthrough gets added as part of GL_CFLAG_GNULIB_WARNINGS
(collected by gl_CC_GNULIB_WARNINGS in m4/gnulib-common.m4). That explains
why I'm not seeing these warnings in gnulib testdirs.

It's probably too hard to teach gcc that error (EXIT_FAILURE, ...) does not
return but error (0, ...) does return. Therefore just disabling this warning
seems the best action.

FWIW grep/coreutils use a die() wrapper to achieve this
for this common idiom.

https://github.com/coreutils/coreutils/commit/dad7ab0b7

cheers,
Pádraig.


Reply via email to