volatile semantics

Daniel Berlin dberlin@dberlin.org
Sat Jul 16 17:32:00 GMT 2005


>> object volatile).
>
> I don't understand your point. given
> 	void Foo (char const * a) { *(char *)a = 5; }
> the compiler generates code to store 5 through the pointer 'a'.  It doesn't turn
> this into a call to 'abort', because it thinks you're writing to const storage.

Is this *always* the cast, or just in the example above?

>
> So, here it appears the compiler does believe the (char *) cast.

I imagine this is due to some workaround in an optimizer for some bug it 
exposed elswhere.

>  Why should it
> not believe a (char volatile *) cast -- unless it can determine the static type
> of the object pointed to?

It appears he was saying that *even if it could determine the static 
type*, the volatile qualifier on the cast *made the object not that type 
anymore*. And i'm not sure why such a thing would apply only to volatile, 
if true.


--Dan



More information about the Gcc mailing list