https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80990
Bug ID: 80990 Summary: cv-qualifiers ignored in variable definition using class template argument deduction Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- This valid C++17 program fails to compile: template<typename T> struct container { }; void must_be_const(const container<int>&) { } void must_be_const(container<int>&) = delete; int main() { container<int> c; const container d = c; must_be_const(d); } $ g++ -std=c++17 const.cc const.cc: In function ‘int main()’: const.cc:10:18: error: use of deleted function ‘void must_be_const(container<int>&)’ must_be_const(d); ^ const.cc:4:6: note: declared here void must_be_const(container<int>&) = delete; ^~~~~~~~~~~~~ The variable 'd' should be const, so should not call the deleted overload.