Re: Pure/const function not getting executed as the first operand to logical OR ( || ) (C++)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux