public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/102627] New: wrong code with "-O1"
@ 2021-10-06  8:37 suochenyao at 163 dot com
  2021-10-06 10:13 ` [Bug tree-optimization/102627] " rguenth at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: suochenyao at 163 dot com @ 2021-10-06  8:37 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-10-22 20:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-06  8:37 [Bug tree-optimization/102627] New: wrong code with "-O1" suochenyao at 163 dot com
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

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).