Failure to call operator=() for return value temporary

Mark Mitchell mark@codesourcery.com
Mon Feb 14 08:46:00 GMT 2000


>>>>> "Richard" == Richard Atterer <atterer@informatik.tu-muenchen.de> writes:

    Richard> /* Hello,

    Richard> I hope this is indeed a bug in GCC and not a subtle error
    Richard> in my code, but I've certainly spent a huge amount of
    Richard> time staring at my SmartPtr class without finding
    Richard> anything.

It is indeed a bug in your code.  A member template `operator=' can
never be a default assignment operator.  You need an explicit:

  SmartPtr& operator=(SmartPtr&);

declaration.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com


More information about the Gcc-bugs mailing list