4 ms·
> 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
by ekiwi 5y 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?
- cbsmith 5y agoThe great thing about simple memory models is they work really well until you think about it. ;-)
- jqpabc123 5y agoWhat 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.
- gpderetta 5y agoAt least in C++, atomicity is part of the type system, and you would have to explicitly reinterpret cast it away.