Bug ID: 84352
           Summary: noreturn function previously declared without the
                    attribute accepted
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot
          Reporter: msebor at gcc dot
  Target Milestone: ---

The C++ standard specifies that "The first declaration of a function shall
specify the noreturn attribute if any declaration of that function specifies
the noreturn attribute."

GCC silently accepts programs thaat violate this rule and emits what could be
viewed by the author of the called function as buggy code.  Other compilers,
including Clang, Intel ICC, and MSVC all reject the test case as expected.

(GCC does issue a -Wsuggest-attribute=noreturn warning for the definition of

$ cat t.C && gcc -S -Wall -Wextra -fdump-tree-optimized=/dev/stdout t.C
int f ();                // not declared noreturn

int g ()
  return f () + f ();    // f() called just once

[[noreturn]] int f ();   // invalid, first f is not noreturn

;; Function g (_Z1gv, funcdef_no=0, decl_uid=2353, cgraph_uid=0,

g ()
  int D.2356;
  int _1;
  int _2;

  <bb 2> :
  f ();


Reply via email to