From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EEA54385842D; Wed, 6 Oct 2021 08:37:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EEA54385842D From: "suochenyao at 163 dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102627] New: wrong code with "-O1" Date: Wed, 06 Oct 2021 08:37:20 +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: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: suochenyao at 163 dot com 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Oct 2021 08:37:21 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102627 Bug ID: 102627 Summary: wrong code with "-O1" Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: suochenyao at 163 dot com Target Milestone: --- ***************************************************************************= **** OS and Platform: CentOS Linux release 7.8.2003 (Core).0, x86_64 GNU/Linux ***************************************************************************= **** Program: int printf(const char *, ...); int a, f, l, m, q, c, d, g; long b, e; struct g { signed h; signed i; unsigned j; unsigned k; }; unsigned n; char o; int *p =3D &m; long(r)(s) { return s && b ?: b; } long v() { l =3D 0 || r(n & o); return q; } void w(int, unsigned, struct g x) { c ?: a; for (; d < 2; d++) *p =3D x.k; } struct g y() { struct g h =3D {3, 908, 1, 20}; for (; g; g++) ; return h; } int main() { long t; struct g u =3D y(); t =3D e << f; w(0, t, u); v(0, 4, 4, 4); printf("%d\n", m); } ***************************************************************************= **** version: $ gcc -v Using built-in specs. COLLECT_GCC=3D/data/bin/gcc-dev/bin/gcc COLLECT_LTO_WRAPPER=3D/data/bin/gcc-dev/libexec/gcc/x86_64-pc-linux-gnu/12.= 0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../configure --prefix=3D/data/bin/gcc-dev/ --disable-multi= lib --enable-languages=3Dc,c++ Thread model: posix Supported LTO compression algorithms: zlib gcc version 12.0.0 20211006 (experimental) (GCC) git ver: bb6194e0b44a8262d8de304be3bd3ee65187772a ***************************************************************************= **** Command Lines: $ gcc -O1 -Wall -Wextra -fno-strict-aliasing -fwrapv a.c -o a1.o a.c: In function =E2=80=98r=E2=80=99: a.c:13:6: warning: type of =E2=80=98s=E2=80=99 defaults to =E2=80=98int=E2= =80=99 [-Wimplicit-int] 13 | long(r)(s) { return s && b ?: b; } | ^ a.c:13:29: warning: the omitted middle operand in =E2=80=98?:=E2=80=99 will= always be =E2=80=98true=E2=80=99, suggest explicit middle operand [-Wparentheses] 13 | long(r)(s) { return s && b ?: b; } | ^ $ gcc a.c -o a0.o a.c: In function =E2=80=98r=E2=80=99: a.c:13:6: warning: type of =E2=80=98s=E2=80=99 defaults to =E2=80=98int=E2= =80=99 [-Wimplicit-int] 13 | long(r)(s) { return s && b ?: b; } | ^ $ ./a1.o 0 $ ./a0.o 20=