[Bug c++/15505] pure virtual destructor not overloaded, but accepted

b dot perschbacher at att dot net gcc-bugzilla@gcc.gnu.org
Fri May 21 03:54:00 GMT 2004


------- Additional Comments From b dot perschbacher at att dot net  2004-05-20 02:34 -------
Subject: Re:  pure virtual destructor not overloaded, but accepted

Sorry I haven't gotten back sooner, but I've been busy tracking down a
different bug.

Anyway I tried your suggestion of also declaring a destructor for the base
class and the compiler throws that back in my face with an overloading
error. So that clearly isn't allowed. Personally I think that virtual
destructors are are best dangerous and at worst useless, I just ran across
it in code I am maintaining.

As for the correctness of a generated function satisfing pure virtual
requirements, that totally circumvents the concept of pure virtual. This
point though goes to my previous statement on the usefulness of such a thing
so I'd just as soon leave this as "whatever."

If the standard explictly states that pure virtual destructors have to be
supported then yes this bug is invalid, but then so is the standard since it
forces the acceptance of invalid(as you put it) code. If the standard does
not explictly declare this then this bug is not invalid, but maybe
mislabeled.

Not forcing the overloading of that destructor, or even allowing a class to
quirkily avoid destruction is so dangerous that I can't express it in words,
but this is what happens with this (the code I am maintaining with this
error compiled and ran on several systems including one with an older gnu
compiler) being an accepted syntax. Just blowing this off is not the right
thing to do here, but "fixing" the compiler may not be an option just yet
either.


Brent
----- Original Message ----- 
From: "bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org>
To: <b.perschbacher@att.net>
Sent: Monday, May 17, 2004 5:07 PM
Subject: [Bug c++/15505] pure virtual destructor not overloaded, but
accepted


>
> ------- Additional Comments From bangerth at dealii dot org  2004-05-17
23:07 -------
> Since you don't explicitly declare the existence of a user-defined
> destructor in the derived class, the compiler synthesizes it automatically
> for you. Thus, the derived class does have a final implementation of the
> pure virtual function. This explains why the compiler (correctly) accepts
> your code.
>
> The standard allows to declare pure destructors, but since base classes
> have to be destroyed anyway, you have to define it in addition. The lack
> of a definition explains why the linker (correctly) complains about a
> function definition.
>
> Thus, your code is invalid and gcc is right, sorry.
>
> Wolfgang
>
> -- 
>            What    |Removed                     |Added
> --------------------------------------------------------------------------
--
>              Status|UNCONFIRMED                 |RESOLVED
>          Resolution|                            |INVALID
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15505
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15505



More information about the Gcc-bugs mailing list