Re: Tiger Build Warnings
Re: Tiger Build Warnings
- Subject: Re: Tiger Build Warnings
- From: Richard Dobson <email@hidden>
- Date: Thu, 23 Jun 2005 09:56:36 +0100
From Meyers, "Effective C++" (2nd Ed), Item 14:
"Make sure base classes have virtual destructors". Among other points:
"[from the C++ standard] if you try to delete a derived class object through a
base class pointer and the base class has a non-virtual destructor, the results
are undefined" ..."What often happens at runtime is that the derived class's
destructor is never called".
Thus, the non-virtual destructor could become the source of memory leaks.
In short: because
(a) this is clearly a base class (or interface; pure virtual base class here)
(b) it has virtual functions
it should have a virtual destructor.
Finally, assuming the definition in Tiger is the same as in Panther, the class
is defined only with a pure virtual constructor, leaving a default destructor to
be defined by the compiler. This default destructor is non-virtual, leading to
the warning. It is probably Ok to define one inline:
virtual ~AUElementCreator() {}
The relevant part of the standard is $12.4: destructors.
Richard Dobson
Jeff Moore wrote:
In general, I like to see warnings from my compilers. They usually
point out potential problems. However, in this particular case, the
warning is a little off-base.
AUElementCreator does not inherit from any other classes, has no member
fields, and has no member functions that aren't pure virtual. In other
words, it is an abstract base class. It's job it to define an
interface. In fact, it is specifically meant to be a mix-in class. Such
a class does not need a destructor, let alone a virtual one. It just
doesn't accomplish anything to call it.
One might even argue that having to define a virtual destructor in this
case is actually bad since it takes away the compiler's ability to
optimize the un-named function completely away, which is what happens
since it won't get any code generated to call it when a sub- class's
destructor is generated.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden