[Bug c++/79605] New: attribute [[noreturn]] accepted in explicit instantiation directives
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Feb 19 21:15:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79605
Bug ID: 79605
Summary: attribute [[noreturn]] accepted in explicit
instantiation directives
Product: gcc
Version: 7.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: ---
G++ accepts __attribute__((noreturn)) in explicit instantiation derectives of
function templates where it is applied to the implicit declaration of the
specialization of the template.
However, the C++ 17 attribute [[noreturn]] "may be applied to the declarator-id
in a function declaration" and is not explicitly permitted to be applied in
other contexts, such as in explicit instantiation derectives. Other compilers,
including Clang 5.0 and EDG eccp 4.11 reject the attribute there but GCC
silently accepts it even in pedantic mode. For conformance, GCC should
diagnose the attribute there as well.
$ cat u.C && gcc -S -Wall -Wunused -Wpedantic u.C
template <class T>
T f () { throw; }
template [[noreturn]] int f<int> ();
template <class T>
int g () { throw; }
template __attribute__ ((noreturn)) int g<int> ();
int f1 ()
{
f<int>(); // not diagnosed (bug)
}
int g1 ()
{
g<int>(); // accepted (okay)
}
More information about the Gcc-bugs
mailing list