Say I have the following code:
int foo () {
int const x = 0;
return x;
}
Is the compiler allowed to move x to the global scope?
What about in the following scenaro? Can res2
vary depending on opimizations?
std::set<int const *> addrs;
int foo () {
int const x = 0;
addrs.insert(&x);
return addrs.size();
}
void bar () {
int res1 = foo();
int res2 = foo();
}