This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Coping with gcc warning due to limitation of gcc analysis?
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Samuel Thibault <samuel dot thibault at gnu dot org>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 29 Jan 2018 16:06:15 +0000
- Subject: Re: Coping with gcc warning due to limitation of gcc analysis?
- Authentication-results: sourceware.org; auth=none
- References: <20180127205417.4eruhvizwf4x2y2c@var.youpi.perso.aquilenet.fr>
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