From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2E137385842F; Fri, 14 Oct 2022 08:32:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E137385842F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665736353; bh=0UEpZjiEXbB3Hh5LcVy9utu2xohd2Yk3DvNoOEKczkc=; h=From:To:Subject:Date:From; b=rGs3ktFrfG9UtzhYw5e7fobyYesxo9MTraarS4iRLnZIaSJW4xZyu5k5VRSx55+te xW9Cn+2ksCZzvMVHHiKbWpuPAxSThOtAJ44yexN+SGftGiNR40aHSIoLkhOVa2SaRq FRhNVPNOR+Gsdtx2Nga/y5YdLv6Q6jA2DYBcEuI0= From: "shaohua.li at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/107257] New: Wrong code at -O2 on x86_64-linux-gnu Date: Fri, 14 Oct 2022 08:32:32 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 13.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=3D107257 Bug ID: 107257 Summary: Wrong code at -O2 on x86_64-linux-gnu Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: shaohua.li at inf dot ethz.ch Target Milestone: --- % gcc-tk -v Using built-in specs. COLLECT_GCC=3Dgcc-tk COLLECT_LTO_WRAPPER=3D/zdata/shaoli/compilers/ccbuilder-compilers/gcc-9f0d4= adabe2035886a1aa8d2ca990a90de000613/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/= lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --disable-multilib --disable-bootstrap --enable-languages=3Dc,c++ --prefix=3D/zdata/shaoli/compilers/ccbuilder-compilers/gcc-9f0d4adabe203588= 6a1aa8d2ca990a90de000613 Thread model: posix Supported LTO compression algorithms: zlib gcc version 13.0.0 20221013 (experimental) (GCC) % % gcc-tk -w -O0 a.c && ./a.out 2 % gcc-tk -w -O2 a.c && ./a.out 0 % % cat a.c l; m; static signed char n(); s() { n(); } signed char n(u) { for (; u <=3D 2; u++) { l =3D 2; for (; l ; l--) { m =3D 2; for (; m; m--) if (u) break; } } } main() { s(2); printf("%d\n", m); } % Compiler explorer: https://godbolt.org/z/z5Mhxaz9E=