From mboxrd@z Thu Jan 1 00:00:00 1970 From: rodrigc@gcc.gnu.org To: gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, philipp.bachmann@obtree.com, rodrigc@gcc.gnu.org Subject: Re: c++/3136: Misleading error message / Bug? Date: Fri, 15 Jun 2001 16:35:00 -0000 Message-id: <20010615233557.10736.qmail@sourceware.cygnus.com> X-SW-Source: 2001-06/msg00690.html List-Id: 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