From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3177E388202D; Mon, 5 Jun 2023 16:24:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3177E388202D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685982245; bh=IyvM0CKT7Hy3MIewMg3FLcpcKnChfmmQkYgwtHtmQXQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dmSWqyIou5FuH5uW+JcE063RGz8ZmMXCxsUgZvO+9jep6u6Rvoq63r8IVKfGvltsB upCvRVddocBDil5rqxbVk7Q+DV4pZFdqCzAzZ7vZ1S7YdlVqKRke9nIWka95e95NgI 3884+tyYXNae5jVzEYihOXnQAIXUWjuGzWNwRaFg= From: "haoxintu at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/110129] Possible wrong-code on -O2 and above (affecting versions from GCC-10.1 onward) Date: Mon, 05 Jun 2023 16:24:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed 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: haoxintu at gmail dot com X-Bugzilla-Status: WAITING 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: Message-ID: In-Reply-To: References: 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=3D110129 --- Comment #2 from Haoxin Tu --- (In reply to Andrew Pinski from comment #1) Oops, my bad. Thank you for pointing this out. I didn't notice the front-en= d is C++ in GodBolt. I have another similar case, can you take a look, please? ``` #include #include struct { int32_t a; } b; int8_t c; int ids =3D 0; void __attribute__((noinline)) marker_1() { printf(" b%db ", 1); ids++; } uint8_t d(int8_t e) { b.a =3D 0; f: for (; e < 8;) { for (; e;) ; goto f; } return b.a; } int main() { int32_t g[1] =3D {0}; if (d(c), g) marker_1(); printf("%d\n", ids); } ``` $gcc-trunk -w -O3 s.c ; ./a.out (hang) $clang-trunk -w -O3 s.c ; ./a.out b1b 1 Godbolt link: https://godbolt.org/z/Kn6cv3hjf GCC hangs on it while Clang can successfully run it. From my understanding,= the goto-statement in function d should not be executed but it seems GCC does. = Did I miss anything here? Thanks!=