[PATCH] PR28901 -Wunused-variable ignores unused const initialised variables
Mon Sep 21 17:10:00 GMT 2015
On Fri, 2015-09-18 at 20:29 -0600, Martin Sebor wrote:
> On 09/15/2015 11:20 AM, Steve Ellcey wrote:
> > I guess it is not the 'const' I think should be handled special but the
> > 'static'. Having unused static variables (const or not) declared in a
> > header file but unused seems reasonable since the header file may be
> > included in multiple .c files each of which uses a subset of the static
> > variables.
> I tend to agree. I suppose diagnosing unused non-const static
> definitions might be helpful but I can't think of a good reason
> to diagnose unused initialized static consts in C. Especially
> since they're not diagnosed in C++.
> Would diagnosing them in source files while avoiding the warning
> for static const definitions in headers be an acceptable compromise?
That seems like a reasonable compromise to me.
More information about the Gcc-patches