http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52269
Bug #: 52269
Summary: [C++11]Body of constexpr function templates
instantiated too eagerly in unevaluated operands
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
The following well-formed code cannot be compiled with GCC 4.7.0 20120211
(experimental) and -std=c++11 flag.
////////////////////////////////////////
template<typename T>
int f(T x)
{
return x.get();
}
// O.K. The body of `f' is not required.
decltype(f(0)) a;
template<typename T>
constexpr int g(T x)
{
return x.get();
}
// Seems to instantiate the body of `g'
// and results in an error.
decltype(g(0)) b;
////////////////////////////////////////
Similar problems also arise in the case of non-template member functions of a
class template.