http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52440
Bug #: 52440 Summary: [C++11] Wrong template argument deduction/substitution failures Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: ai.az...@gmail.com Created attachment 26790 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26790 Output of -v option and preprocessed file I can't find anything to prevent the following code from compiling; ///////////////////////////////////////////////////////// template<bool> struct V { typedef void type; }; template<typename T> struct X { template<typename> static constexpr bool always_true() { return true; }; template<typename U, typename = typename V<always_true<U>()>::type> X(U &&) {} // Line 18 }; int main() { X<int> x(42); // Line 23 } ///////////////////////////////////////////////////////// However, GCC complains about deduction/substitution failure; main.cpp: In function 'int main()': main.cpp:23:14: error: no matching function for call to 'X<int>::X(int)' main.cpp:23:14: note: candidates are: main.cpp:18:3: note: template<class U, class> X::X(U&&) main.cpp:18:3: note: template argument deduction/substitution failed: main.cpp:8:8: note: constexpr X<int>::X(const X<int>&) main.cpp:8:8: note: no known conversion for argument 1 from 'int' to 'const X<int>&' main.cpp:8:8: note: constexpr X<int>::X(X<int>&&) main.cpp:8:8: note: no known conversion for argument 1 from 'int' to 'X<int>&&' The constructor template in line 18 should always succeed in template argument deduction/substitution and be used for the invocation in Line 23. My guess is that this is a bug of GCC.