https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80985
Bug ID: 80985
Summary: -Wnoexcept-type should not produce a warning for
inlined template functions
Product: gcc
Version: 7.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: john at jlindgren dot net
Target Milestone: ---
This simple C++ example generates a warning with gcc 7.1.1:
template<class Func>
void call (Func f)
{
f ();
}
void func () noexcept
{
}
int main ()
{
call (func);
return 0;
}
$ g++ -std=c++11 -Wall -c test.cc
test.cc:2:6: warning: mangled name for ‘void call(Func) [with Func = void (*)()
noexcept]’ will change in C++17 because the exception specification is part of
a function type [-Wnoexcept-type]
void call (Func f)
^~~~
IMHO this warning is a false positive. The mangled name of call() doesn't
matter because it is a template function which is called from the same
compilation unit in which it is defined, and it will almost certainly be
inlined. Please consider refining the triggers for -Wnoexcept-type so that it
does not produce a warning in a case like this one.
gcc-multilib 7.1.1-3 (Arch Linux)
$ gcc --version
gcc (GCC) 7.1.1 20170528