This is the mail archive of the 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: [PATCH] C undefined behavior fix

-----Original Message-----
From: jtv []
Sent: Monday, January 07, 2002 4:16 PM
To: Tim Hollebeek
Cc: Bernard Dautrevaux; '';;;;;
Subject: Re: [PATCH] C undefined behavior fix

On Mon, Jan 07, 2002 at 05:28:32PM -0500, Tim Hollebeek wrote:
> You're not allowed to be that smart wrt volatile.  If the programmer
> says the value might change unpredictably and should not be optimized,
> then It Is So and the compiler must respect that even if it determines
> It Cannot Possibly Happen.

Naturally I hope you're right.  But how does that follow from the
I have to admit I don't have a copy handy.  :(

Let's say we have this simplified version of the problem:

	int a = 3;
		volatile int b = 10;
		a += b;

Is there really language in the Standard preventing the compiler from
constant-folding this code to "int a = 13;"?


In the above case it is unlikely that folding would present a problem,
but volatile was created because hardware, or even seemingly unrelated
software, can modify even the most unlikely memory locations.   If you
want to break device drivers, go ahead and optimize your compiler.  



The only thing dummer than a cow is a man who thinks he's smarter than a

To unsubscribe from this list: send the line "unsubscribe linux-kernel"
the body of a message to
More majordomo info at
Please read the FAQ at

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