This is the mail archive of the libc-alpha@sourceware.org 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: Coping with gcc warning due to limitation of gcc analysis?


On Sat, 27 Jan 2018, Samuel Thibault wrote:

> What is the glibc-preferred way to deal with this? Of course I could
> just initialize saved to a dumb value like -1 but the reader might
> wonder why unless we put a blunt comment, and a smarter compiler might
> later warn "-1 set in `saved' is never used"...

As a general rule: we avoid such initializers that are only intended to 
suppress warnings rather than ever to have that initial value used.  If 
the code can be changed to avoid the warning without being less efficient, 
that's preferred.  Otherwise, use the DIAG_*_NEEDS_COMMENT macros (with 
appropriate explanatory comment detailing the warning and why it's a false 
positive).  Using -Wno-error=* or -Wno-* in the Makefiles is less 
desirable, and generally only appropriate if the pragmas don't work for 
some reason (e.g. no option controlling the warning in question to use in 
a pragma) or can't be used (e.g. file copied verbatim from an upstream 
source not using such pragmas and we don't want local changes to it).

-- 
Joseph S. Myers
joseph@codesourcery.com


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