]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/62017 (AddressSanitizer reports *-buffer-overflow in destructor when multip...
authorJason Merrill <jason@redhat.com>
Fri, 13 Feb 2015 22:14:07 +0000 (17:14 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 13 Feb 2015 22:14:07 +0000 (17:14 -0500)
PR c++/62017
* decl.c (begin_destructor_body): Only clobber the as-base part of
*this.

From-SVN: r220699

gcc/cp/ChangeLog
gcc/cp/decl.c

index 61640dd8e8ad272243f2804c6a9c386aa061c8a8..90f2923f99e102c0ac95ed55965a931faacb4769 100644 (file)
@@ -1,3 +1,9 @@
+2015-02-13  Jason Merrill  <jason@redhat.com>
+
+       PR c++/62017
+       * decl.c (begin_destructor_body): Only clobber the as-base part of
+       *this.
+
 2015-02-11  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
index 4cc386e117f9f415e7983f424708d0bd3ae6eee0..631ce9191325e7496e9a2100272ea63c094e3e20 100644 (file)
@@ -13669,10 +13669,12 @@ begin_destructor_body (void)
 
       /* Insert a cleanup to let the back end know that the object is dead
         when we exit the destructor, either normally or via exception.  */
-      tree clobber = build_constructor (current_class_type, NULL);
+      tree btype = CLASSTYPE_AS_BASE (current_class_type);
+      tree clobber = build_constructor (btype, NULL);
       TREE_THIS_VOLATILE (clobber) = true;
-      tree exprstmt = build2 (MODIFY_EXPR, current_class_type,
-                             current_class_ref, clobber);
+      tree bref = build_nop (build_reference_type (btype), current_class_ptr);
+      bref = convert_from_reference (bref);
+      tree exprstmt = build2 (MODIFY_EXPR, btype, bref, clobber);
       finish_decl_cleanup (NULL_TREE, exprstmt);
 
       /* And insert cleanups for our bases and members so that they