diff options
author | Jason Merrill <jason@redhat.com> | 2014-09-20 22:42:40 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2014-09-20 22:42:40 -0400 |
commit | 1dc7b1f2086931a2b885ebb3cd09cc7a7639c276 (patch) | |
tree | e6055b836dcbe9fef031dc101d0c7df83726c73a | |
parent | 1c2c9440d4d2dd62346d6dafd452c9ad74bd858a (diff) | |
download | gcc-1dc7b1f2086931a2b885ebb3cd09cc7a7639c276.zip gcc-1dc7b1f2086931a2b885ebb3cd09cc7a7639c276.tar.gz gcc-1dc7b1f2086931a2b885ebb3cd09cc7a7639c276.tar.bz2 |
re PR c++/62017 (AddressSanitizer reports *-buffer-overflow in destructor when multiple virtual inheritance is used)
PR c++/62017
* decl.c (begin_destructor_body): Only clobber the as-base part of
*this.
From-SVN: r215427
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 8 |
2 files changed, 11 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2b53728..857f58d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-09-20 Jason Merrill <jason@redhat.com> + + PR c++/62017 + * decl.c (begin_destructor_body): Only clobber the as-base part of + *this. + 2014-09-19 Jason Merrill <jason@redhat.com> PR c++/61392 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 59dada7..fe5a4af 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -13808,10 +13808,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 |