> const int i = 100;
> int *p = (int *)&i;
> *p = 200;
> Modifying a true constant is undefined behavior.
Just one more question, what about volatile keyword?
Can I do something like:
volatile const int i = 100;
int * = (int*)&i;
*p = 200;
std::cout << i;
I try this example under VC7.0 and receive the same result.
Is this undefined behavior or compler bug?
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]