From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 295483858D20; Thu, 28 Sep 2023 13:57:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 295483858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1695909474; bh=AtnLuAHw4YTUAgLE808uRbszbG6zpN8MoHkYaCFuSkg=; h=From:To:Subject:Date:From; b=Js5Q/LtwDtp6uN2TMHSRI/BtAb7Xp91Q1vJIIv95WIsYqALEehW2RVmSm6FR7xepM ROexzgaX17VmmNS9KxSDh4+bEB+e5xl3JqnAsiuwNiVrOvPq/EquicRdYGTq2mvzV5 2eUBbqCsXA1vXBlRH1c3l7KB30qdRyTUdwO5iB84= From: "shaohua.li at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111631] New: Wrong code at -Os on x86_64-linux-gnu since r14-3217-g4d6132e5932 Date: Thu, 28 Sep 2023 13:57:53 +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: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: shaohua.li at inf dot ethz.ch 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 keywords bug_severity priority component assigned_to reporter cc 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=3D111631 Bug ID: 111631 Summary: Wrong code at -Os on x86_64-linux-gnu since r14-3217-g4d6132e5932 Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: shaohua.li at inf dot ethz.ch CC: rguenth at gcc dot gnu.org Target Milestone: --- gcc at -Os produced the wrong code. Bisected to r14-3217-g4d6132e5932 Compiler explorer: https://godbolt.org/z/Yj9bq1ecs $ cat a.c int printf(const char *, ...); short a, f, i; static const int *e; short *g; long h; int main() { { unsigned j =3D i; a =3D 1; for (; a; a++) { { long b =3D j, d =3D h; int c =3D 0; while (d--) *(char *)b++ =3D c; } if (e) break; } j && (*g)--; const int **k =3D &e; *k =3D 0; } printf("%d\n", f); } $ $ gcc -O0 a.c && ./a.out 0 $ gcc -Os a.c && ./a.out Segmentation fault $ gcc -fsanitize=3Daddress,undefined a.c && ./a.out 0 $=