This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/3136: Misleading error message / Bug?
- To: gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, philipp dot bachmann at obtree dot com, rodrigc at gcc dot gnu dot org
- Subject: Re: c++/3136: Misleading error message / Bug?
- From: rodrigc at gcc dot gnu dot org
- Date: 15 Jun 2001 23:35:57 -0000
Synopsis: Misleading error message / Bug?
State-Changed-From-To: open->closed
State-Changed-By: rodrigc
State-Changed-When: Fri Jun 15 16:35:57 2001
State-Changed-Why:
gcc is not in error. There is a bug in your code.
The error message may be misleading though.
On line 74, of your test case:
return self.getMe();
The compiler creates a temporary variable
to store the result of getMe(), since self
is not a const reference.
What is happening is that on line 74:
return self.getMe();
When you return this temporary value, you are passing
it to a copy constructor which takes derived_t&
(without a const) as value. This is not allowed in C++.
Your options are to make self a const parameter to the
whatHappensHere() function.
This is similar to a bug report described here:
http://gcc.gnu.org/ml/gcc/2001-06/msg00765.html
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3136&database=gcc