This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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: GCC warnings for unused global variables


> 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.


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