[Bug c++/84352] New: noreturn function previously declared without the attribute accepted
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Feb 12 23:08:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84352
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 gnu.org
Reporter: msebor at gcc dot gnu.org
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
g().)
$ 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,
symbol_order=0)
g ()
{
int D.2356;
int _1;
int _2;
<bb 2> :
f ();
}
More information about the Gcc-bugs
mailing list