2009/12/10 sergio borghese: > > Now my question is: is it correct that the compiler enforces the > constantness of the variable, even tought it states in the warning > that the const qualifier has been discarded?
the calls to printf can be optimised to printf("i: %dn", 0) so it doesn't use the value of i, because the compiler knows that the value of i cannot be changed by a valid program. You didn't show what foo does, but if you change the value of a const variable the program's behaviour is undefined, so you can't rely on any particular behaviour.