This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/57857] New: argument of decltype used by no return value warning
- From: "potswa at mac dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 09 Jul 2013 02:42:12 +0000
- Subject: [Bug c++/57857] New: argument of decltype used by no return value warning
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57857
Bug ID: 57857
Summary: argument of decltype used by no return value warning
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: potswa at mac dot com
The following program complains that "declval() must not be used!" in a static
assertion if -Wall is passed. But declval() is only present in the unevaluated
context of a decltype specifier.
The issue seems to be linked to the generation of the warning message. But the
warning message will be present without the static_assert if the function has
more than one exit point, such as if(0) throw; or if(0) return; (the latter
using -fpermissive).
#include <utility>
template <typename U>
auto foo() -> decltype(std::declval<U>() + std::declval<U>());
template <typename T>
decltype(foo<T>()) bar(T) {
// if ( 0 ) throw;
}
int main()
{ bar(1); }