GCC warnings for unused global variables

Geoff Keating geoffk@geoffk.org
Fri May 2 03:48:00 GMT 2003


> Date: Thu, 1 May 2003 19:43:42 -0700
> From: Richard Henderson <rth@redhat.com>

> On Thu, May 01, 2003 at 11:05:18AM -0700, Geoff Keating wrote:
> > This is still the case; it's easy to suppress the warning by adding an
> > appropriate attribute, or by use of 'volatile' (at least, I hope
> > 'volatile' works, if not it can be fixed).
> 
> Why in the world would "volatile" affect this in any way?

The C standard says:

> An object that has volatile-qualified type may be modified in ways
> unknown to the implementation or have other unknown side effects.

That sounds exactly like a description of the case here: the 'unknown
side effect' is that what(1) reads the string.

Then later it says:

> at every sequence point the value last stored in the
> object shall agree with that prescribed by the abstract machine,

For instance, at program startup (in this case) the abstract machine
says the string contains a particular value, and how can it do that if
it is optimized away?

-- 
- Geoffrey Keating <geoffk@geoffk.org>



More information about the Gcc mailing list