This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH: PR 19811


This patch fixes PR c++/19811, a case where we crashed when applying
"delete []" to an incomplete class type.

Tested on x86_64-unknown-linu-gnu, applied on the mainline.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2005-02-09  Mark Mitchell  <mark@codesourcery.com>

	PR c++/19811
	* call.c (build_op_delete_call): Check COMPLETE_TYPE_P before
	attempting name lookup.

2005-02-09  Mark Mitchell  <mark@codesourcery.com>

	PR c++/19811
	* g++.dg/init/delete1.C: New test.

Index: cp/call.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/call.c,v
retrieving revision 1.529
diff -c -5 -p -r1.529 call.c
*** cp/call.c	10 Feb 2005 00:34:26 -0000	1.529
--- cp/call.c	10 Feb 2005 07:49:23 -0000
*************** build_op_delete_call (enum tree_code cod
*** 3922,3932 ****
  
    type = strip_array_types (TREE_TYPE (TREE_TYPE (addr)));
  
    fnname = ansi_opname (code);
  
!   if (IS_AGGR_TYPE (type) && !global_p)
      /* In [class.free]
  
         If the result of the lookup is ambiguous or inaccessible, or if
         the lookup selects a placement deallocation function, the
         program is ill-formed.
--- 3922,3934 ----
  
    type = strip_array_types (TREE_TYPE (TREE_TYPE (addr)));
  
    fnname = ansi_opname (code);
  
!   if (CLASS_TYPE_P (type) 
!       && COMPLETE_TYPE_P (complete_type (type))
!       && !global_p)
      /* In [class.free]
  
         If the result of the lookup is ambiguous or inaccessible, or if
         the lookup selects a placement deallocation function, the
         program is ill-formed.
Index: testsuite/g++.dg/init/delete1.C
===================================================================
RCS file: testsuite/g++.dg/init/delete1.C
diff -N testsuite/g++.dg/init/delete1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/init/delete1.C	10 Feb 2005 07:50:09 -0000
***************
*** 0 ****
--- 1,7 ----
+ // PR c++/19811
+ 
+ class C; // { dg-error "forward" }
+ 
+ void foo(void *p) {
+   delete [] ((C*)p) ; // { dg-error "" }
+ }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]