Hacker News new | ask | show | jobs
by ekiwi 1808 days ago
> Access to any global variable should always occur direct from memory.

What if your function takes a pointer that might be pointing to a global variable? Does that mean that all accesses through a pointer are now excempt from optimization unless the compiler can prove that the pointer will never point to a global variable?

2 comments

The great thing about simple memory models is they work really well until you think about it. ;-)
What if your function takes a pointer that might be pointing to an "atomic" variable?

Pointers can be used to circumvent most safety measures. If you obscure the access, you should assume responsibility for the result.

At least in C++, atomicity is part of the type system, and you would have to explicitly reinterpret cast it away.