From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5CC7A3858421; Sun, 18 Dec 2022 19:46:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5CC7A3858421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671392761; bh=+FGAOLsBu1DZpC07mWO92pwOhsaYjBwqsm8rCmJ17Dg=; h=From:To:Subject:Date:From; b=fLbOVKcO+DJXa8MCuIakeh2pMyR5mPw2D3sciP3WnfX2QyicQh4hSUbm5k1I8ZrTc TpEEsjoNc36tZLo6EJHnGGui70WztmrqSpy2HJ/kYjZu6Zsja/9PJ6PwvZH+MtV7wZ bgCaUStFxVPDBYmTPIWPZzCl4vwo42hVuojz/ar4= From: "vsevolod.livinskiy at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/108166] New: [12/13 Regression] Wrong code with -O2 Date: Sun, 18 Dec 2022 19:46:01 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vsevolod.livinskiy 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=3D108166 Bug ID: 108166 Summary: [12/13 Regression] Wrong code with -O2 Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vsevolod.livinskiy at gmail dot com Target Milestone: --- Link to the Compiler Explorer: https://godbolt.org/z/j8coqj375 Reproducer: #include bool a, b; int d, c; const int &e(const int &f, const int &g) { return !f ? f : g; } int main() { c =3D e(b, 0) > ((b ? d : b) ?: 8); a =3D b ? d : b; printf("%d\n", a); if (a !=3D 0) __builtin_abort(); } Error: >$ g++ -O2 driver.cpp && ./a.out=20 1 Aborted (core dumped) >$ g++ -O0 driver.cpp && ./a.out=20 0 gcc version 13.0.0 20221216 (2fdc8546b5c6cb1fe254e40b5bdd19ed6fbb44da)=