Andreas Schwab writes: > "Dave Korn" <[EMAIL PROTECTED]> writes: > > > But it's really legal to cast away const? > > All that matters is the effective type of the accessed object, see 6.5#7.
It's not clear to me that it's legal to convert (const int*) to (int*). 6.3.2.3, Pointers, says 2 For any qualifier q, a pointer to a non-q-qualified type may be converted to a pointer to the q-qualified version of the type; the values stored in the original and converted pointers shall compare equal. It doesn't seem to me to give any permission to do the conversion the other way. But that wouldn't make any difference to this case, because you can still do int i = 0; void bar() { i = 2; } void foo (const int *pi) { print (*pi); bar(); print (*pi); } int main() { foo (&i); return 0; } For what it's worth: we have a lot of fields in Java that are known never to change, and to be able to explain that to the optimizers would be a big boost. Andrew.