Kohei Yoshida wrote:

> On Fri, 2008-05-09 at 20:01 +0200, Mathias Bauer wrote:
>> Another interesting discovery was that removing ctors can be dangerous
>> at times because some compilers automatically create default or copy
>> ctors for classes even if they aren't used.
> 
> One technique to work around this is to put the default and copy ctors
> in the private section of the class declaration, and leave their
> definitions out.  That should prevent the compiler from automatically
> generating those ctors, and if any code constructs that class via
> default or copy constructor, then the link should fail.

Yes, this is always a good practice.

In the current situation the problem didn't happen in the class where
the ctor was removed but in some derived classes. These classes formerly
had a ctor (and so it wasn't necessary to declare a default ctor, be it
private or not) that was removed in the patch and now some compiler
thought it might be a good idea to create a default ctor (and didn't
find one in the base class that still had another ctor but no default ctor).

A good example for your approach to have a look before applying the
patch. :-)
And perhaps a hint that always adding a (private) default ctor and copy
ctor is something to think about.

I found removing the whole class better than playing with declared (but
not implemented) default ctors. At the end a class whose ctor is never
called can't be much useful. :-)

Ciao,
Mathias

-- 
Mathias Bauer (mba) - Project Lead OpenOffice.org Writer
OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
Please don't reply to "[EMAIL PROTECTED]".
I use it for the OOo lists and only rarely read other mails sent to it.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to