public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/97493] New: generate wrong code with "-Os -fno-toplevel-reorder -frename-registers"
@ 2020-10-19 13:50 suochenyao at 163 dot com
  2020-10-19 14:06 ` [Bug c/97493] " jakub at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: suochenyao at 163 dot com @ 2020-10-19 13:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97493

            Bug ID: 97493
           Summary: generate wrong code with "-Os -fno-toplevel-reorder
                    -frename-registers"
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: suochenyao at 163 dot com
  Target Milestone: ---

Description:
I think gcc generates wrong code with -Os -fno-toplevel-reorder
-frename-registers.
But no difference is found with optimization levels.
No message and difference occurs with "gcc -Wall -Wextra" and
"-fno-strict-aliasing -fwrapv"
*******************************************************************************
OS and Platform:
CentOS Linux release 7.8.2003 (Core), x86_64 GNU/Linux
*******************************************************************************
Program:
int printf(const char *, ...);
union uuu{
  short a;
  long b;
} c={0};
long *d = &c.b;
short *e = &c.a;
short f=0;
int main() {
  *d = 3;
  f = ++*e;
  printf("%d\n", c.a);
}
*******************************************************************************
Gcc Version:
$ gcc -v
Using built-in specs.
COLLECT_GCC=/home/suocy/bin/gcc-dev/bin/gcc
COLLECT_LTO_WRAPPER=/home/suocy/bin/gcc-dev/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/suocy/bin/gcc-dev
--disable-multilib --enable-languages=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20201018 (experimental) (GCC)
*******************************************************************************
Command Line:
$ gcc -Wall -Wextra -fno-strict-aliasing -fwrapv -O0 a.c -o a.out0
$ gcc -Wall -Wextra -fno-strict-aliasing -fwrapv -O1 a.c -o a.out1
$ gcc -Wall -Wextra -fno-strict-aliasing -fwrapv -O2 a.c -o a.out2
$ gcc -Wall -Wextra -fno-strict-aliasing -fwrapv -O3 a.c -o a.out3
$ gcc -Wall -Wextra -fno-strict-aliasing -fwrapv -Os a.c -o a.outs
$ gcc -Wall -Wextra -fno-strict-aliasing -fwrapv -Os -fno-toplevel-reorder
-frename-registers a.c -o a.outf
$ ./a.out0 > out0
$ ./a.out1 > out1
$ ./a.out2 > out2
$ ./a.out3 > out3
$ ./a.outs > outs
$ ./a.outf > outf
$ diff out0 out1
$ diff out0 out2
$ diff out0 out3
$ diff out0 outs
$ diff out0 outf
1c1
< 4
---
> 1

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

end of thread, other threads:[~2020-10-30 15:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-19 13:50 [Bug c/97493] New: generate wrong code with "-Os -fno-toplevel-reorder -frename-registers" suochenyao at 163 dot com
2020-10-19 14:06 ` [Bug c/97493] " jakub at gcc dot gnu.org
2020-10-19 15:23 ` rguenth at gcc dot gnu.org
2020-10-19 15:39 ` jakub at gcc dot gnu.org
2020-10-20 12:59 ` suochenyao at 163 dot com
2020-10-20 12:59 ` suochenyao at 163 dot com
2020-10-30 15:28 ` suochenyao at 163 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).