public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "suochenyao at 163 dot com" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-102627-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102627 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 = &m; long(r)(s) { return s && b ?: b; } long v() { l = 0 || r(n & o); return q; } void w(int, unsigned, struct g x) { c ?: a; for (; d < 2; d++) *p = x.k; } struct g y() { struct g h = {3, 908, 1, 20}; for (; g; g++) ; return h; } int main() { long t; struct g u = y(); t = e << f; w(0, t, u); v(0, 4, 4, 4); printf("%d\n", m); } ******************************************************************************* version: $ gcc -v Using built-in specs. COLLECT_GCC=/data/bin/gcc-dev/bin/gcc COLLECT_LTO_WRAPPER=/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=/data/bin/gcc-dev/ --disable-multilib --enable-languages=c,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 ‘r’: a.c:13:6: warning: type of ‘s’ defaults to ‘int’ [-Wimplicit-int] 13 | long(r)(s) { return s && b ?: b; } | ^ a.c:13:29: warning: the omitted middle operand in ‘?:’ will always be ‘true’, suggest explicit middle operand [-Wparentheses] 13 | long(r)(s) { return s && b ?: b; } | ^ $ gcc a.c -o a0.o a.c: In function ‘r’: a.c:13:6: warning: type of ‘s’ defaults to ‘int’ [-Wimplicit-int] 13 | long(r)(s) { return s && b ?: b; } | ^ $ ./a1.o 0 $ ./a0.o 20
next reply other threads:[~2021-10-06 8:37 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-10-06 8:37 suochenyao at 163 dot com [this message] 2021-10-06 10:13 ` [Bug tree-optimization/102627] " rguenth at gcc dot gnu.org 2021-10-06 10:32 ` [Bug rtl-optimization/102627] [11/12 Regression] " jakub at gcc dot gnu.org 2021-10-06 10:42 ` jakub at gcc dot gnu.org 2021-10-07 19:54 ` vmakarov at gcc dot gnu.org 2021-10-08 16:54 ` cvs-commit at gcc dot gnu.org 2021-10-11 8:32 ` [Bug rtl-optimization/102627] [11 " jakub at gcc dot gnu.org 2021-10-14 16:11 ` cvs-commit at gcc dot gnu.org 2021-10-14 16:15 ` vmakarov at gcc dot gnu.org 2021-10-22 20:11 ` hjl.tools at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-102627-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).