This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR c++/35317: ICE with operator delete[] and ellipsis
- From: Simon Martin <simartin at users dot sourceforge dot net>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 08 Mar 2008 13:42:40 +0100
- Subject: [PATCH] Fix PR c++/35317: ICE with operator delete[] and ellipsis
Hi all.
The following valid snippet gives an ICE with 4.2, 4.3 and the trunk
=== cut here ===
struct A
{
void operator delete[] (void*, ...);
};
=== cut here ===
This leads to a segmentation fault in 'type_requires_array_cookie' that
analyzes the delete[] operator(s) that have two arguments to determine
if there is one with a second argument of type 'std::size_t'. The
problem lies in the code that checks if there are exactly two arguments:
it checks if the TREE_CHAIN for the second argument is void_type_node,
without ensuring that the second argument is not NULL_TREE (which is the
case when it's an ellipsis). The attached patch fixes this by skipping
delete[] operators with an ellipsis as second argument.
I have successfully regtested it on x86_64-apple-darwin-9. Is it OK for
the mainline? For 4.3? For 4.2?
Best regards,
Simon
:ADDPATCH c++:
2008-03-08 Simon Martin <simartin@users.sourceforge.net>
PR c++/35317
* class.c (type_requires_array_cookie): Do not consider delete[]
operators with an ellipsis as second argument.
Index: gcc/cp/class.c
===================================================================
--- gcc/cp/class.c (revision 133023)
+++ gcc/cp/class.c (working copy)
@@ -4121,6 +4121,10 @@ type_requires_array_cookie (tree type)
second_parm = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (fn)));
if (second_parm == void_list_node)
return false;
+ /* Do not consider this function if its second argument is an
+ ellipsis. */
+ if (!second_parm)
+ continue;
/* Otherwise, if we have a two-argument function and the second
argument is `size_t', it will be the usual deallocation
function -- unless there is one-argument function, too. */
2008-03-08 Simon Martin <simartin@users.sourceforge.net>
PR c++/35317
* g++.dg/other/dtor2.C: New test.
/* PR c++/35317 */
/* { dg-do "compile" } */
struct A
{
void operator delete[] (void*, ...);
};