public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/103908] New: gcc 7.5.0 (and earlier) miscompile asm goto in O1 on x86-64
@ 2022-01-04 21:13 mathieu.desnoyers at efficios dot com
  2022-01-04 21:51 ` [Bug rtl-optimization/103908] " redi at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: mathieu.desnoyers at efficios dot com @ 2022-01-04 21:13 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103908
           Summary: gcc 7.5.0 (and earlier) miscompile asm goto in O1 on
                    x86-64
           Product: gcc
           Version: 7.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mathieu.desnoyers at efficios dot com
  Target Milestone: ---

Created attachment 52122
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52122&action=edit
Reproducer for asm goto miscompilation in O1 (x86-64) gcc-7.5.0 and prior

gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
Target: x86_64-linux-gnu

Configured with: ../src/configure -v --with-pkgversion='Ubuntu
7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-7
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie
--with-system-zlib --with-target-system-zlib --enable-objc-gc=auto
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none --without-cuda-driver
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix

How to reproduce:

% gcc-7 -O1 -c -o hoisting.o hoisting.i
% objdump -S hoisting.o


hoisting.o:     file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <foo>:
   0:   c7 05 00 00 00 00 01    movl   $0x1,0x0(%rip)        # a <foo+0xa>
   7:   00 00 00 
   a:   c3                      retq 

Expected behavior:

% gcc-8 -O1 -c -o hoisting.o hoisting.i
% objdump -S hoisting.o

hoisting.o:     file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <foo>:
   0:   83 3d 00 00 00 00 00    cmpl   $0x0,0x0(%rip)        # 7 <foo+0x7>
   7:   74 10                   je     19 <foo+0x19>
   9:   e8 00 00 00 00          callq  e <foo+0xe>
   e:   c7 05 00 00 00 00 01    movl   $0x1,0x0(%rip)        # 18 <foo+0x18>
  15:   00 00 00 
  18:   c3                      retq   
  19:   e8 00 00 00 00          callq  1e <foo+0x1e>
  1e:   eb ee                   jmp    e <foo+0xe>

This issue appears to be fixed in gcc 8.1.0, but I did not find any bugzilla
entry documenting this.

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

end of thread, other threads:[~2024-02-14 17:23 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-04 21:13 [Bug c/103908] New: gcc 7.5.0 (and earlier) miscompile asm goto in O1 on x86-64 mathieu.desnoyers at efficios dot com
2022-01-04 21:51 ` [Bug rtl-optimization/103908] " redi at gcc dot gnu.org
2022-01-04 21:54 ` redi at gcc dot gnu.org
2022-01-04 21:55 ` redi at gcc dot gnu.org
2022-01-04 22:00 ` [Bug rtl-optimization/103908] gcc miscompile asm goto for O1 pinskia at gcc dot gnu.org
2022-01-04 23:01 ` jakub at gcc dot gnu.org
2022-01-06  8:31 ` cvs-commit at gcc dot gnu.org
2022-01-06  8:32 ` jakub at gcc dot gnu.org
2022-01-24  9:21 ` cvs-commit at gcc dot gnu.org
2022-01-24  9:29 ` jakub at gcc dot gnu.org
2022-05-10  8:22 ` cvs-commit at gcc dot gnu.org
2022-05-11  6:23 ` cvs-commit at gcc dot gnu.org
2022-05-11  6:36 ` jakub at gcc dot gnu.org
2024-02-14 17:23 ` pinskia at gcc dot gnu.org

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