The following code fails to compile because the copy constructor has a non
const argument - it works if the const qualifier is added to the input:

class t1 {

public:
  t1(t1& tr);

  t1 dosomething(const t1& v) const;
  t1 dosamethingagain(const t1& v) const { return dosomething(v); }
  t1 operator%=(const t1& v) const { return dosomething(v); }
};

The compiler error messages are:
test.cpp: In member function `t1 t1::dosamethingagain(const t1&) const':
test.cpp:7: error: no matching function for call to `t1::t1(t1)'
test.cpp:4: error: candidates are: t1::t1(t1&)
test.cpp: In member function `t1 t1::operator%=(const t1&) const':
test.cpp:8: error: no matching function for call to `t1::t1(t1)'
test.cpp:4: error: candidates are: t1::t1(t1&)


-- 
           Summary: Compiler error for copy constructor with non const input
           Product: gcc
           Version: 3.3.6
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: richard at rggibbs dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25231

Reply via email to