This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/52269] New: [C++11]Body of constexpr function templates instantiated too eagerly in unevaluated operands


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]