[Bug middle-end/88575] gcc got confused by different comparison operators
joseph at codesourcery dot com
gcc-bugzilla@gcc.gnu.org
Mon Dec 31 19:14:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88575
--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
On Sat, 22 Dec 2018, bugzilla@poradnik-webmastera.com wrote:
> In test() gcc is not able to determine that for a==b it does not have to
> evaluate 2nd comparison and can use value of a if 1st comparison is true. When
> operators are swapped like in test2() or are the same, code is optimized.
>
> [code]
> double test(double a, double b)
> {
> if (a <= b)
> return a < b ? a : b;
> return 0.0;
> }
You didn't give compilation options, but if a and b are +0 and -0 in some
order, the first comparison is true but b must be returned instead of a
(in the absence of -fno-signed-zeros or an option implying it).
More information about the Gcc-bugs
mailing list