re PR c++/33324 (ICE on new array of objects with virtual destructors.)
authorDavid Daney <ddaney@avtrex.com>
Sun, 9 Sep 2007 23:31:35 +0000 (23:31 +0000)
committerDavid Daney <daney@gcc.gnu.org>
Sun, 9 Sep 2007 23:31:35 +0000 (23:31 +0000)
PR c++/33324
* init.c (build_new_1):  Use POINTER_PLUS_EXPR instead of MINUS_EXPR
to calculate cookie_ptr.

From-SVN: r128312

gcc/cp/ChangeLog
gcc/cp/init.c

index ad342b6e78527ca7cbc196c37ecd5458dd89aa67..cdbffb1e0702329b861ae96ed1d510d96ab6d236 100644 (file)
@@ -1,3 +1,9 @@
+2007-09-09  David Daney  <ddaney@avtrex.com>
+
+       PR c++/33324
+       * init.c (build_new_1):  Use POINTER_PLUS_EXPR instead of MINUS_EXPR
+       to calculate cookie_ptr.
+
 2007-09-08  Jason Merrill  <jason@redhat.com>
 
        PR c++/33342
index 1aa732c26b05d28c2dab5a7d02cd19d81d9f807a..cafc721710701136bcfa8f821465dea925916555 100644 (file)
@@ -1930,8 +1930,10 @@ build_new_1 (tree placement, tree type, tree nelts, tree init,
       if (targetm.cxx.cookie_has_size ())
        {
          /* Also store the element size.  */
-         cookie_ptr = build2 (MINUS_EXPR, build_pointer_type (sizetype),
-                              cookie_ptr, size_in_bytes (sizetype));
+         cookie_ptr = build2 (POINTER_PLUS_EXPR, size_ptr_type, cookie_ptr,
+                              fold_build1 (NEGATE_EXPR, sizetype,
+                                           size_in_bytes (sizetype)));
+
          cookie = build_indirect_ref (cookie_ptr, NULL);
          cookie = build2 (MODIFY_EXPR, sizetype, cookie,
                           size_in_bytes(elt_type));