From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DB9743830B77; Wed, 4 Oct 2023 17:09:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB9743830B77 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696439356; bh=VimL99FdeKZydy1bJWyeojgNiAqJJP2rNdqQwvKTpHM=; h=From:To:Subject:Date:From; b=Dw1rQuS8FnuhY29VjWDTBzCOZVhBJdGL1FM80Tqax4Z6YwFeSdtJjUKeZooyomqk4 W7ivs0L5nHjBfFX2PYV/Zg5G9tI2bFLPrRkZI2E6Fi62XZMlZmRQ7StKCbEV/SwgKU SQLQU6NUzzjz14511Gq0flHPMCDuVU2aa4NtiiME= From: "alonzakai at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug web/111694] New: Wrong behavior for signbit of negative zero when optimizing Date: Wed, 04 Oct 2023 17:09:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: web X-Bugzilla-Version: 13.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: alonzakai at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111694 Bug ID: 111694 Summary: Wrong behavior for signbit of negative zero when optimizing Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: web Assignee: unassigned at gcc dot gnu.org Reporter: alonzakai at gmail dot com Target Milestone: --- This behaves incorrectly in 13.2.0 with -O1 and above, but is correct in 12, 11, and 10. It is also correct in 13.2.0 without optimizations. Testcase: #include #include void test(double l, double r) { if (l =3D=3D r && l =3D=3D 0 && (signbit(l) || signbit(r))) { puts("one is negative"); } } int main() { test(0.0, -0.0); test(-0.0, 0.0); } This should print "one is negative" twice, but only does so once in 13.2.0 = with -O1: $ gcc-13 a.c -O1 ; ./a.out one is negative $ gcc-13 a.c -O0 ; ./a.out one is negative one is negative $=