[Bug c/44974] New: Function with attribute noreturn omits a call to another function with noreturn

John dot Tytgat at aaug dot net gcc-bugzilla@gcc.gnu.org
Sun Jul 18 04:12:00 GMT 2010


4.6.0 20100713 r162159 cross, target arm-unknown-eabi, newlib 1.18

Compile:

arm-unknown-eabi-gcc -O1 -S -o bug.s bug.c

With bug.c:

--8<--
extern void foo1 (int status) __attribute__ ((__noreturn__));

extern void _Exit (int status) __attribute__ ((__noreturn__));

extern void foo3 (int status) __attribute__ ((__noreturn__));

void
foo1 (int status)
{

  _Exit (status);
}

void
_Exit (int status)
{
  foo3 (status);
}
--8<--

Results in:

--8<--
        .global _Exit
        .type   _Exit, %function
_Exit:
        @ Function supports interworking.
        @ Volatile: function does not return.
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        stmfd   sp!, {r3, lr}
        bl      foo3
        .size   _Exit, .-_Exit
        .align  2
        .global foo1
        .type   foo1, %function
foo1:
        @ Function supports interworking.
        @ Volatile: function does not return.
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        @ link register save eliminated.
        bx      lr
        .size   foo1, .-foo1
--8<--

I.e. foo1() does not call _Exit() while it should.

Changing -O1 into another level makes it work and changing _Exit() into another
function name (but also marked as noreturn) makes it work as well.


-- 
           Summary: Function with attribute noreturn omits a call to another
                    function with noreturn
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: John dot Tytgat at aaug dot net
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: arm-unknown-eabi


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44974



More information about the Gcc-bugs mailing list