This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/80990] New: cv-qualifiers ignored in variable definition using class template argument deduction
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 06 Jun 2017 16:27:09 +0000
- Subject: [Bug c++/80990] New: cv-qualifiers ignored in variable definition using class template argument deduction
- Auto-submitted: auto-generated
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.