https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79021
Bug ID: 79021 Summary: attribute noreturn on function template ignored in generic lambda Product: gcc Version: 6.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: akim.demaille at gmail dot com Target Milestone: --- When a generic lambda calls a function templates declared noreturn, we still get warnings about missing return values. $ cat foo.cc template <typename T> [[noreturn]] int f(T) { throw "error"; } int g() { f(12); } template <typename T> int h(T) { f(12); } int main() { auto g = [](auto a) -> int { f(a); }; } $ g++-mp-6 --version g++-mp-6 (MacPorts gcc6 6.2.0_2) 6.2.0 Copyright (C) 2016 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ g++-mp-6 -std=c++14 foo.cc -Wreturn-type foo.cc: In lambda function: foo.cc:21:38: warning: no return statement in function returning non-void [-Wreturn-type] auto g = [](auto a) -> int { f(a); }; ^ $ clang++-mp-3.9 -std=c++14 foo.cc -Wreturn-type $ Please note that: - if f is not templated, there is no warning - if the lambda is not generic, there is no warning - if calling from a function template rather than from a generic template (i.e., the function h), it does not trigger any warning (even if I do use h).