c++/1925: should issue diagnostic for pure virtual called in dtor
bh@techhouse.org
bh@techhouse.org
Fri Feb 9 17:36:00 GMT 2001
>Number: 1925
>Category: c++
>Synopsis: should issue diagnostic for pure virtual called in dtor
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Fri Feb 09 17:36:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Benoit Hudson
>Release: 2.95.2
>Organization:
>Environment:
>Description:
Consider the code in how-to-repeat.
The call to f() in the destructor has undefined semantics,
because it's a call to a pure virtual whereas we don't
make virtual function calls in the destructor (and
constructor).
It would be nice to get a better diagnostic than the
current, a linker error that A::f() isn't defined.
>How-To-Repeat:
#include <stdio.h>
struct A {
virtual ~A() {
f();
}
virtual void f() = 0;
};
struct B : public A {
virtual void f() {
printf("B\n");
}
};
int main() {
B b;
}
>Fix:
Put the dtor call to destroy in the subclass.
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list