This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug inline-asm/32811] Cannot flag inline assembler code "noreturn"
- From: "adam at consulting dot net dot nz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Jul 2010 23:19:33 -0000
- Subject: [Bug inline-asm/32811] Cannot flag inline assembler code "noreturn"
- References: <bug-32811-8549@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from adam at consulting dot net dot nz 2010-07-13 23:19 -------
This issue needs to be revisited with the advent of asm goto:
__attribute__ ((noreturn)) void noreturn_via_asm_goto() {
loop:
asm goto ("jmp %l[loop]\n" : : : : loop);
}
int main() {}
$ gcc-4.5 -std=gnu99 -O3 noreturn.c && objdump -d -m i386:x86-64:intel|less
noreturn.c: In function ?noreturn_via_asm_goto?:
noreturn.c:4:1: warning: ?noreturn? function does return
00000000004004c0 <noreturn_via_asm_goto>:
4004c0: eb fe jmp 4004c0 <noreturn_via_asm_goto>
4004c2: c3 ret
4004c3: 66 66 66 66 2e 0f 1f nop WORD PTR cs:[rax+rax*1+0x0]
4004ca: 84 00 00 00 00 00
The warning is spurious and the return instruction is not elided. This can
matter with threaded interpreters jumping to/from code with a native code
length equal to a multiple of 16 bytes. In the worse case this extra byte can
double the space consumed by hundreds of tiny functions.
Best approach would be to actually trust the programmer's use of the noreturn
explicit compiler directive in all circumstances. Do not emit a return
instruction when the compiler has been explicitly told that a particular
function does not return. By all means warn that it appears to the compiler
that the code path is going to drop through to the next address in memory.
Thanks,
Adam
--
adam at consulting dot net dot nz changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |adam at consulting dot net
| |dot nz
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32811