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

Paul Eggert eggert@cs.ucla.edu
Sat Nov 22 05:14:00 GMT 2014


Joseph Myers wrote:
> it's warning about str[1] for an array
> wint_t str[1] for which only str[0] is valid and only str[0] exists to be
> initialized (but the - unreachable - code is, after propagating some
> constants, accessing str[1]).

Yeouch, GCC is even more confused than I thought.

Instead of masking the GCC bug, how about changing the libc source slightly so 
that the bug isn't tickled?  The attached patch does that, and this fixes the 
bug for me (x86-64, both GCC 4.9.2 and GCC 4.8.3) without having to fiddle with 
any pragmas.  As a bonus this patch seems to make the resulting machine code 
slightly more efficient; it's smaller, anyway.

We did this sort of thing with gnulib etc. too.  If memory serves, occasionally 
the buggy warnings were signs of other trouble within GCC, so it wasn't 
unreasonable to change the code to pacify the compiler.  I do try to file GCC 
bug reports for this sort of thing but I'm not perfect in that regard.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-fnmatch-work-around-GCC-compiler-warning-bug-with-un.patch
Type: text/x-diff
Size: 2569 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20141122/eed2d275/attachment.bin>


More information about the Libc-alpha mailing list