[patch] Fix PR c++/26071: ICE declaring destructor virtual and static
Volker Reichelt
reichelt@igpm.rwth-aachen.de
Thu Feb 2 09:04:00 GMT 2006
The following invalid code snippet causes an ICE:
struct A
{
virtual static ~A();
};
'
Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
The crash happens at the following position:
if (virtualp && staticp == 2)
{
error ("member %qD cannot be declared both virtual and static", dname);
staticp = 0;
}
This is because dname is NULL. The following patch fixes that by
setting dname also in the destructor case. We then get the message:
bug.cc:3: error: member '~A' cannot be declared both virtual and static
Btw, the ICE is a regression from GCC 3.4.x.
Before we got the error message:
bug.cc:3: error: member `A' cannot be declared both virtual and static
which is not quite correct, but tolerable.
Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Ok for mainline, 4.1 branch, 4.0 branch?
Regards,
Volker
:ADDPATCH C++:
2006-02-02 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/26071
* decl.c (grokdeclarator): Set dname also for destructor.
===================================================================
--- gcc/gcc/cp/decl.c (revision 110467)
+++ gcc/gcc/cp/decl.c (working copy)
@@ -6746,6 +6746,7 @@
type = TREE_OPERAND (decl, 0);
name = IDENTIFIER_POINTER (constructor_name (type));
+ dname = decl;
}
break;
===================================================================
2006-02-02 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/26071
* g++.dg/other/virtual2.C: New test.
===================================================================
--- gcc/gcc/testsuite/g++.dg/other/virtual2.C 2005-08-29 00:25:44 +0200
+++ gcc/gcc/testsuite/g++.dg/other/virtual2.C 2006-02-01 22:01:57 +0100
@@ -0,0 +1,7 @@
+// PR c++/26071
+// { dg-do compile }
+
+struct A
+{
+ virtual static ~A(); // { dg-error "virtual" }
+};
===================================================================
More information about the Gcc-patches
mailing list