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]

Re: c++/3136: Misleading error message / Bug?


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


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