This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Add macros for diagnostic control, use them in locale/weightwc.h

A couple of other thoughts.

First, the syntax DIAG_IGNORE (-Wmaybe-uninitialized, ...) is too clever and brittle. Too clever, because in C code it looks like it's subtracting 'uninitialized' from the negative of 'Wmaybe'. Too brittle, because suppose GCC adds a warning option syntax with commas in it? "-Wsuggest-attribute=format,noreturn", say? Then DIAG_IGNORE (-Wsuggest-attribute=format,noreturn, ...) won't work because of C's tokenization rules. For both of these reasions it would be better to use a string, e.g., DIAG_IGNORE ("-Wmaybe-uninitialized", ...).

More important, I looked through some of the Gnulib and GNU utilities code that deals with working around bugs in GCC's diagnostics generation, and -Wmaybe-uninitialized in particular has caused us so much grief that we typically silence it in a different way, which I should mention. We use a macro definition like this:

  #ifdef lint
  # define IF_LINT(Code) Code
  # define IF_LINT(Code) /* empty */

and then write declarations like this:

  off_t size IF_LINT ( = 0);

when GCC wrongly complains that 'size' may be used unininitialized. That way, people who want to use -Wmaybe-uninitialized can get clean compiles by compiling with '-Wmaybe-uninitialized -Dlint', and people who don't care about this stuff can omit the options and get slightly more-efficient code. Obviously there are some pitfalls in this approach but overall its benefits outweigh its cost for us. In particular, it lets us carefully isolate the uninitialized-warning bug, whereas the DIAG_IGNORE approach is more of a blunderbuss that disables the warning in a too-large region because of GCC's bugs.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]