http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52748
Bug #: 52748 Summary: [C++11] N3276 changes to decltype Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: zeratul...@hotmail.com The C++11 standard section 5.2.2 pararaph 11 states that: "If a function call is a prvalue of object type [and] if the function call is [...] the operand of a decltype-specifier [...], a temporary object is not introduced for the prvalue. The type of the prvalue may be incomplete. [Note: as a result, storage is not allocated for the prvalue and it is not destroyed; thus, a class type is not instantiated as a result of being the type of a function call in this context." This addition was made late in the C++11 standardization process; its rationale is described in the paper N3276 [1] It seems GCC does not currently support this. In fact, when run on the "trivial example" given in N3276, GCC gets into an infinite loop and, if left running, uses up all the memory in the system (!) (Should I file that as a separate issue?) Here is the example (WARNING - may exhaust your system's virtual memory if you're not careful): template<class T> struct S; template<class X, class Y> struct pair {}; template<class T> S<T> wrap(T) { return 0; } template<class T> struct S { S(int = 0) {} decltype(wrap(pair<T,T>())) foo() { return 0; } // ERROR S<pair<T,T> > bar() { return 0; } // OK }; S<int> s; [1] http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2011/n3276.pdf