GCC warnings for unused global variables
Joe Buck
jbuck@synopsys.com
Fri May 2 16:35:00 GMT 2003
> I'm trying to say that "volatile" is not a *reliable* feature to use
> to write robust code with reproducible behaviour.
>
> | static volatile int foo;
> |
> | void test (void)
> | {
> | foo = 1;
> | foo = 1;
> | }
> |
> | Does your statement mean that you believe the compiler is allowed to
> | optimize this into:
> | void test (void)
> | {
> | foo = 1;
> | }
> | ?
On Fri, May 02, 2003 at 05:18:02PM +0200, Gabriel Dos Reis wrote:
> If it can determine that does nto change the behaviour of whole
> program, yes, it is permitted to do so.
Gaby, surely you know that the reason that volatile is in the language
is to allow C to be used to write code that interacts with hardware,
or with other invisible software that the compiler can't see. If you
can find language in the standard that suggests that one of the writes
to foo can be legally eliminated, it's defect report time.
> | The answer clearly *must* be NO, otherwise you've just defined
> | volatile into total uselessness.
>
> I've not defined anything, it has been all there.
See above.
More information about the Gcc
mailing list