https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85883
Bug ID: 85883 Summary: class template argument deduction fails in new-expression Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: barry.revzin at gmail dot com Target Milestone: --- Slightly reduced from https://stackoverflow.com/q/50478019/2069064: template <typename T1, typename T2> struct Bar { Bar(T1, T2) { } }; int main() { auto x = Bar(1, 2); auto y = new Bar(3, 4); } The declaration of x works, the declaration of y fails with: <source>: In function 'int main()': <source>:10:26: error: class template argument deduction failed: auto y = new Bar(3, 4); ^ <source>:10:26: error: no matching function for call to 'Bar()' <source>:4:5: note: candidate: 'template<class T1, class T2> Bar(T1, T2)-> Bar<T1, T2>' Bar(T1, T2) { } ^~~ <source>:4:5: note: template argument deduction/substitution failed: <source>:10:26: note: candidate expects 2 arguments, 0 provided auto y = new Bar(3, 4); ^