Bruno Haible <br...@clisp.org> writes:
> Hi Sam, Hi Bruno, > >> The configure test in gl_FUNC_FREXP_WORKS within m4/frexp.m4 triggers >> a Clang warning/error when Clang is passed >> -Werror=incompatible-pointer-types. > > Gnulib does not support CC or CPPFLAGS or CFLAGS values with -Werror at > configure time. Neither with gcc nor with clang. Yes, I understand that. But Clang is likely to make this change to its default and -Werror=... was just a way of emulating that. gnulib _does_ have to cater to the default strictness of compilers. > > The reason is that [1] > "Many GCC warning options usually don’t point to mistakes in the code; > these warnings enforce a certain programming style. It is a project > management decision whether you want your code to follow any of these > styles. Note that some of these programming styles are conflicting. > You cannot have them all; you have to choose among them." > > For example, there is a warning option that attempts to enforce > explicit casts (no implicit conversions), and there is a warning option > that attempts to enforce no explicit casts. When you use such a warning > option together with -Werror, you are attempting to enforce a certain > programming style on the configure tests. Obviously the configure test > snippets cannot obey different, conflicting programming styles. Yep, completely on board with that & I get it. The only reason I reported this is because there's a reasonable chance this will be Clang's new behaviour by default (see below). > >> /tmp/foo.c: In function ‘main’: >> /tmp/foo.c:59:21: warning: passing argument 2 of ‘memcmp’ discards >> ‘volatile’ qualifier from pointer target type [-Wdiscarded-qualifiers] >> 59 | if (memcmp (&y, &x, sizeof x)) >> | ^~ > > There is nothing wrong with this code (m4/frexp.m4:159, m4/frexpf.m4:83). > > We don't want to add a cast here, because — as Paul argues — casts can make > code more difficult to maintain in the long run. Yes, I agree it's pedantic, but it's still going to be an issue if (as planned) Clang flips '-Wincompatible-pointer-types' to error out by default unless they carve out an exception for qualifiers here. I'll advocate that they do, of course. I just came across it while checking for configure changes w/ recent GCC changes. > > Bruno > > [1] https://www.gnu.org/software/gnulib/manual/html_node/manywarnings.html