[Bug c++/25231] New: Compiler error for copy constructor with non const input

2005-12-02 Thread richard at rggibbs dot com
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



[Bug c++/25231] Compiler error for copy constructor with non const input

2005-12-02 Thread richard at rggibbs dot com


--- Comment #2 from richard at rggibbs dot com  2005-12-02 21:11 ---
I really don't think that the reply addresses the question. If a function
returns an object it has to call a copy constructor. This code compiles if the
copy constructor is declared as
  t1(const t1& tr);
but fails if declared as
  t1(t1& tr);
I don't see how the reply deals with this issue.


-- 

richard at rggibbs dot com changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |


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