This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/2869: virtual derived class destructor bug
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/2869: virtual derived class destructor bug
- From: luppy at mutanttek dot com
- Date: 18 May 2001 21:47:15 -0000
- Reply-To: luppy at mutanttek dot com
>Number: 2869
>Category: c++
>Synopsis: virtual derived class destructor bug
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri May 18 14:56:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: luppy@mutanttek.com
>Release: >= gcc version 2.95.2 20000220
>Organization:
>Environment:
gcc version 2.95.4 20010506 (Debian prerelease): failed
gcc version 2.95.3 20010315 (Debian release): failed
gcc version 2.95.2 20000220 (Debian GNU/Linux): failed
gcc version 2.95.2-6 19991024 (cygwin experimental): passed
gcc version 2.95.2 19991024 (release): passed
>Description:
See "how to repeat"
>How-To-Repeat:
This program can test the exsistence of the bug:
#include <stdio.h>
class cA{
public:
virtual void Test(class cB *b)=0;
};
class cB:virtual public cA{
public:
~cB(){
cB *t=this;
t->Test(this);
}
virtual void Test(cB *b){
if(this==b) printf("Test passed :-)\n");
else printf("Test failed :-(\n");
}
};
class cC:virtual public cA{
};
class cD:public cB,public cC{
};
int main(int argc,char *argv[]){
cD d;
return 0;
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-c++src; name="main.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="main.cpp"
I2luY2x1ZGUgPHN0ZGlvLmg+CmNsYXNzIGNBewoJcHVibGljOgoJCXZpcnR1YWwgdm9pZCBUZXN0
KGNsYXNzIGNCICpiKT0wOwp9OwpjbGFzcyBjQjp2aXJ0dWFsIHB1YmxpYyBjQXsKCXB1YmxpYzoK
CQl+Y0IoKXsKCQkJY0IgKnQ9dGhpczsKCQkJdC0+VGVzdCh0aGlzKTsKCQl9CgkJdmlydHVhbCB2
b2lkIFRlc3QoY0IgKmIpewoJCQlpZih0aGlzPT1iKSBwcmludGYoIlRlc3QgcGFzc2VkIDotKVxu
Iik7CgkJCWVsc2UgICAgICAgIHByaW50ZigiVGVzdCBmYWlsZWQgOi0oXG4iKTsKCQl9Cn07CmNs
YXNzIGNDOnZpcnR1YWwgcHVibGljIGNBewp9OwpjbGFzcyBjRDpwdWJsaWMgY0IscHVibGljIGND
ewp9OwppbnQgbWFpbihpbnQgYXJnYyxjaGFyICphcmd2W10pewoJY0QgZDsKCXJldHVybiAwOwp9
Cg==