(j3.2006) F08/0099
Malcolm Cohen
malcolm
Thu Oct 24 05:09:55 EDT 2013
>This means that a processor might decide that "n+n" is less expensive
>than "2*n", and use that instead.
Sure, with probability zero.
>Is the processor allowed to fetch the volatile N twice, perhaps getting
>an even value the first time and an odd value the second time, thereby
>printing 'Size of A is odd'?
Sure, with probability zero. Memory accesses have always been slower than
register accesses.
>If not, should we amend 7.1.5.2.4p2 to prohibit transformations that
>change the number of references to volatile variables (or maybe only the
>ones that increase the number of references), at least in specification
>expressions?
No. Only a blithering idiot would write code like this. Volatile variables are
basically only hand-waved anyway, going down the rabbit hole of specifying
precisely handwaved semantics would be a waste of time, effort, and ink. The
original specification of volatile (everything in the whole program becomes
processor-dependent if the word volatile appears anywhere) would be better than
that.
If it were not for the incompatibility, I'd be more inclined to prohibit
volatile variables from appearing in specification expressions at all.
Cheers,
--
................................Malcolm Cohen, Nihon NAG, Tokyo.
More information about the J3
mailing list