So I took a look at the x86 assembly with O1 just -fno-inline. So interprocedural analysis still happens. Now, is there a specific name for the type of optimization where the compiler simply decides to drop the return value. Is this related to return value optimization (though RVO usually discusses objects and explicit copy constructors)? ________________________________________ From: Xi Ruoyao <xry111@xxxxxxxxxxxxxxxx> Sent: Sunday, January 23, 2022 10:02 AM To: Vishal Subramanyam Cc: gcc-help@xxxxxxxxxxx Subject: Re: Pure/const function not getting executed as the first operand to logical OR ( || ) (C++) On Sun, 2022-01-23 at 09:56 +0000, Vishal Subramanyam wrote: > This still doesn't explain why an O1 level optimization can violate > the standard by not evaluating the first operand. It's not violating the standard. The standard says division-by-zero is an undefined behavior, so the compiler can do anything. > What optimization is my code triggering with -fno-inline? My function > clearly has a return value, so how did the compiler > decide that the return value doesn't matter? -- Xi Ruoyao <xry111@xxxxxxxxxxxxxxxx> School of Aerospace Science and Technology, Xidian University