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

            Bug ID: 100068
           Summary: inconsistent handling of noreturn on nested function
                    declarations
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

For the test case below, in f1() GCC (in both C and C++ modes) emits just one
call to g1() while Clang, ICC emit two.  Visual C gives an error for the
noreturn mismatch between the two declarations of g1().

In f0(), all compilers emit just one call to g0() (Visual C with optimization;
without optimization it warns about the second call to g0() being unreachable).

$ cat a.c && gcc -O -S -Wall -fdump-tree-optimized=/dev/stdout a.c

void f0 (void)
{
  extern __attribute__ ((noreturn)) int g0 (void);

  {
    extern int g0 (void);
  }

  g0 ();
  g0 ();   // eliminated by all tested compilers
}

void f1 (void)
{ 
  extern int g1 (void);

  {
    extern __attribute__ ((noreturn)) int g1 (void);
  }

  g1 ();
  g1 ();   // eliminated by GCC, emitted by Clang and ICC
} 


;; Function f0 (f0, funcdef_no=0, decl_uid=1943, cgraph_uid=1, symbol_order=0)
(executed once)

void f0 ()
{
  <bb 2> [local count: 1073741824]:
  g0 ();

}



;; Function f1 (f1, funcdef_no=1, decl_uid=1952, cgraph_uid=2, symbol_order=1)
(executed once)

void f1 ()
{
  <bb 2> [local count: 1073741824]:
  g1 ();

}

Reply via email to