http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54542
Bug #: 54542 Summary: SFINAE bug: handling new expressions Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: ts...@mail.ru g++ 4.8.0 20120909 (experimental) fails to compile the following well-defined code: template <class T> void f(decltype(new T(1, 2)) *) { T(1, 2); } template <class T> void f(...) {} int main() { f<int>(0); } COLLECT_GCC_OPTIONS='-v' '-std=c++11' '-shared-libgcc' '-mtune=generic' '-march=pentiumpro' test.cpp: In substitution of ‘template<class T> void f(decltype (new T)*) [with T = <missing>]’: test.cpp:12:17: required from here test.cpp:2:14: error: new initializer expression list treated as compound expression [-fpermissive] void f(decltype(new T(1, 2)) *) ^ test.cpp: In substitution of ‘template<class T> void f(decltype (new T)*) [with T = int]’: test.cpp:12:17: required from here test.cpp:2:14: error: new initializer expression list treated as compound expression [-fpermissive] test.cpp:2:38: error: new initializer expression list treated as compound expression [-fpermissive] void f(decltype(new T(1, 2)) *) ^ ‘ Internal compiler error: Error reporting routines re-entered. Compiler version info: Target: i686-pc-linux-gnu Configured with: ../configure --prefix=../target --enable-languages=c,c++ Thread model: posix GNU C++ (GCC) version 4.8.0 20120909 (experimental) (i686-pc-linux-gnu) compiled by GNU C version 4.8.0 20120909 (experimental), GMP version 5.0.2, MPFR version 3.1.0, MPC version 0.8.2 Explanation: When T is int, the new-expression is ill-formed and the error occurs in immediate context, so the former f should be excluded from the set of candidate functions due to substitution failure.