This answer at this question explains how changing a constant variable via dereferencing a pointer to it's address works (apparently by creating a new variable).
const int i = 10;
*(int *)&i = 5;
std::cout << &i << "\t" << i << "\n"; // 0x7fff6b325244 10
std::cout << &*(int *)&i << "\t" << *(int *)&i << "\n"; // 0x7fff6b325244 5
With &*(int *)&i
I was trying to get the address of the new variable that the previous answer was talking about. How do I find where this new variable is stored?
*(int *)&i
is showing a different value, so there has to be a new variable.
Compiled on g++ 5.4.0, Ubuntu 16.04