This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: volatile semantics
Richard Henderson wrote:
> I've got no interest in reading a thread with 250 messages wherein
> language lawyers battle it out in a no-holds-barred grudge match.
yeah, I can understand that :)
> Would someone like to summarize, preferably with a test case that
> one side assumes to be miscompiled?
Issue 1.
void Foo (char *ptr) {
*(volatile char *)ptr;
}
can the read be deleted? GCC 4 deletes it.
IMHO, no it cannot be deleted (when we do not know what object PTR points to).
Issue 2
can we delete the read, when we do determine that PTR points to a non-volatile
object. I.e.
char c;
*(volatile char *)&c; // can this read be deleted?
IMHO, the standard is unclear. It seems to me that deleting the read is not
disallowed.
Issue 3
void Foo (volatile char *ptr) {
*(char *)ptr;
}
Again, is this read deleteable? IMHO, yes.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk