https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86439
Bug ID: 86439 Summary: CTAD with deleted copy constructor fails due to deduction-guide taking by value Product: gcc Version: 8.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: barry.revzin at gmail dot com Target Milestone: --- Reduced from: https://stackoverflow.com/q/51244047/2069064 struct NC { NC() = default; NC(NC const&) = delete; NC& operator=(NC const&) = delete; }; template <int> struct C { C(NC const&); }; C(NC) -> C<0>; int main() { NC nc; C c(nc); } clang accepts. gcc rejects this program with: <source>: In function 'int main()': <source>:16:11: error: class template argument deduction failed: C c(nc); ^ <source>:16:11: error: use of deleted function 'NC::NC(const NC&)' <source>:3:5: note: declared here NC(NC const&) = delete; ^~ <source>:12:1: note: initializing argument 1 of 'C(NC)-> C<0>' C(NC) -> C<0>; ^ But nowhere do we need to copy NC here. CTAD doesn't require invoking the function, just picking the best viable candidate. And once we pick C<0>, actually constructing a C<0> is fine since it doesn't require a copy.