문제

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