This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/52269] New: [C++11]Body of constexpr function templates instantiated too eagerly in unevaluated operands
- From: "ai.azuma at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 16 Feb 2012 07:46:59 +0000
- Subject: [Bug c++/52269] New: [C++11]Body of constexpr function templates instantiated too eagerly in unevaluated operands
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: ai.azuma@gmail.com
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.