سؤال

If I mark a variable as volatile I get a guaranteed read with each access in the code.

But what about non-volatile variables?

Is at least one read per function/block guaranteed, or can the value be optimized across function boundaries?

هل كانت مفيدة؟

المحلول

Why would function boundaries be important, if inlining (even un-provoked, i.e., no inline) could eradicate them anyway?

I.O.W.: Yes, almost anything is possible under the as-if rule: As long as the program behaves as if the compiler hadn't optimized anything, it's allowed to do anything to it. (And the borders of that criterion are pretty hazy, too. For example, eliminating copies is allowed to the compiler's heart's content, and missing side-effects be damned.)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top