This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/80990] New: cv-qualifiers ignored in variable definition using class template argument deduction


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]