Bug 56983 - Label in asm deleted after call to non-returning function
Summary: Label in asm deleted after call to non-returning function
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-16 18:38 UTC by silvioricardoc
Modified: 2013-04-16 18:42 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Sample bug-causing code. (172 bytes, text/x-csrc)
2013-04-16 18:39 UTC, silvioricardoc
Details

Note You need to log in before you can comment on or make changes to this bug.
Description silvioricardoc 2013-04-16 18:38:13 UTC
gcc -v:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.7/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.2-2ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1) 

uname -a:
Linux silvioricardoc-laptop 3.5.0-27-generic #46-Ubuntu SMP Mon Mar 25 20:00:05 UTC 2013 i686 i686 i686 GNU/Linux

Command-line:
gcc -Wall -Wextra code.c


Description:
GCC eliminates all code following a call to a non-returning function, even if this code includes an asm label that can be jumped to. In the latter case, it will generate the "jump-to-label" assembly output, but the code will fail to link due to the missing label.

The problem may be the fact that GCC does not know when an asm label can be jumped into, but in this case, the correct solution should be to act conservatively and keep that part of the code intact.
Comment 1 silvioricardoc 2013-04-16 18:39:50 UTC
Created attachment 29885 [details]
Sample bug-causing code.
Comment 2 Jakub Jelinek 2013-04-16 18:42:41 UTC
The testcase is of course invalid, you can't jump out of inline asm without telling the compiler about it.
You can use asm goto to tell the compiler about it, then it wouldn't optimize it away (of course, the label is then a C label, not one hidden in assembly).