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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.)