4 ms·
Register behavior is what you want essentially all of the time. So we’d just have to write `register` all over the place for no gain. “Don’t optimize this, rea
by wat10000 2y ago
Register behavior is what you want essentially all of the time. So we’d just have to write `register` all over the place for no gain.
“Don’t optimize this, read and write it even if you think it’s not necessary” is a very rare case so it shouldn’t be the default. If you want it, use the volatile keyword.
There’s no need to reword the standard to assume the register behavior if the variable’s address hasn’t been taken. That’s already how it works. In this example, if you escape the value of `&x`, it’s not legal to optimize this function to always return 1.