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.