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

            Bug ID: 102578
           Summary: false alarm on noreturn via static function
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eggert at cs dot ucla.edu
  Target Milestone: ---

Created attachment 51537
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51537&action=edit
False alarm with 'gcc -O2 -S'

I ran into this problem when compiling GNU Coreutils and simplified it to the
attached testcase noreturn.c. The shell command 'gcc -O2 -S noreturn.c' outputs
this:

noreturn.c: In function 'xalloc_die':
noreturn.c:13:1: warning: 'noreturn' function does return
   13 | }
      | ^

This is a false alarm because xalloc_die calls the static function
cleanup_fatal which calls 'exit'.

Although I can pacify GCC by declaring cleanup_fatal to be _Noreturn, I
shouldn't have to complicate the source code for a static function when GCC can
(and already does) figure this stuff out automatically.

This is GCC 11.2.1 20210728 (Red Hat 11.2.1-1) x86-64.

Reply via email to