From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 597653858C52; Fri, 15 Sep 2023 07:42:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 597653858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694763725; bh=LNGcNnG8a1ldezccUfSPoPTarcDOBBg8OHlw1XO9WYg=; h=From:To:Subject:Date:From; b=NBxf1cEQRf8O1DiOL97NPQHHF3kH6dIw/ygH3jW9e+AhOvJFM8OAhvqBDRsT7ZVnH wvGDANxk6xgYzwKVmZzsLo6keziyJ1loO56TXcftF2sVWNfuq+mxes21NQb3Hp90KA Cs+PQlGT32Bwrd6hxqZIP8UEP2QK2kyHfM1jgJy8= From: "shaohua.li at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111422] New: Wrong code at -O3 on x86_64-linux-gnu Date: Fri, 15 Sep 2023 07:42:05 +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: 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 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=3D111422 Bug ID: 111422 Summary: Wrong code at -O3 on x86_64-linux-gnu Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: shaohua.li at inf dot ethz.ch Target Milestone: --- gcc at -O3 produced the wrong code. Compiler explorer: https://godbolt.org/z/3b4v478TG $ cat a.c int printf(const char *, ...); int a, b; int *c =3D &b; unsigned d; char e; int f=3D1; int i(int k, char *l) { if (k < 6) return a; l[0] =3D l[1] =3D l[k - 1] =3D 8; return 0; } int m(int k) { char g[11]; int h =3D i(k, g); return h; } int main() { for (; b < 8; b =3D b + 1) ; int j; int *n[8]; j =3D 0; for (;18446744073709551608U + m(*c) + *c + j < 2; j++){ n[j] =3D &f; } for (; e <=3D 4; e++) d =3D *n[0] =3D=3D f; printf("%d\n", d); } $ $ gcc -O0 a.c && ./a.out 1 $ gcc -O3 a.c && ./a.out Segmentation fault $ gcc -O3 -fwrapv a.c && ./a.out=20 Segmentation fault $ gcc -fsanitize=3Daddress,undefined a.c && ./a.out 1 $=