How does a compiler, C or C++, (for example, gcc) honors the const
declaration?
For example, in the following code, how does the compiler keeps track that the variable ci
is const
and cannot be modified?
int
get_foo() {
return 42;
}
void
test()
{
int i = get_foo();
i += 5;
const int ci = get_foo();
// ci += 7; // compile error: assignment of read-only variable ?ci?
}