From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E9F613858D37; Sun, 19 Nov 2023 05:24:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E9F613858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700371489; bh=fbBG4aHpvG1+CMZNMsY1cRjMs/FEVvbvdKTLfQ05NN8=; h=From:To:Subject:Date:From; b=sV3/V2GV1eVmgFEAtDq8nSuzW5COqo8BuQ3/t3NGbOtZ0RHHzH8P5oM/3oXENV/d0 npAbvdx4/9vhgdsU9Bqy8FhwSF7Vnza8W7oAoZeiprxOf/UJFvvpJHuesVfWtXu/dN PuSINWcrHzikeMu/NegyP7HulWkDAcEDMWbl87PE= From: "zhendong.su at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/112616] New: wrong code at -O{s,2,3} on x86_64-linux-gnu Date: Sun, 19 Nov 2023 05:24:49 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: zhendong.su 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=3D112616 Bug ID: 112616 Summary: wrong code at -O{s,2,3} on x86_64-linux-gnu Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: zhendong.su at inf dot ethz.ch Target Milestone: --- It appears to be a regression from 9.*, and affects 10.* and later. Compiler Explorer: https://godbolt.org/z/GxdzdqTjd [510] % gcctk -v Using built-in specs. COLLECT_GCC=3Dgcctk COLLECT_LTO_WRAPPER=3D/local/suz-local/software/local/gcc-trunk/libexec/gcc= /x86_64-pc-linux-gnu/14.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-trunk/configure --disable-bootstrap --enable-checking=3Dyes --prefix=3D/local/suz-local/software/local/gcc-trunk --enable-sanitizers --enable-languages=3Dc,c++ --disable-werror --enable-mu= ltilib Thread model: posix Supported LTO compression algorithms: zlib gcc version 14.0.0 20231118 (experimental) (GCC)=20 [511] %=20 [511] % gcctk -O1 small.c; ./a.out [512] %=20 [512] % gcctk -O3 small.c [513] % ./a.out Segmentation fault [514] %=20 [514] % cat small.c unsigned a; int b, d, e, f =3D 2, g, h =3D 1, *i =3D &b; volatile int c =3D 1; static int *o() { long m =3D ~a; int j =3D f / b, k =3D f - 1, n =3D m << -1 / ~g / k; if (j && n) c; return &e; } static long p() { int *q =3D 0, **r =3D &q; if (c) { *i =3D h; *r =3D o(); } return *q; } int main() { p(); int *l =3D 0; if (d) c =3D *l; return 0; }=