This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [committed] Don't instrument clobbers with asan (PR c++/62017)
- From: Jason Merrill <jason at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Sat, 20 Sep 2014 22:42:01 -0400
- Subject: Re: [committed] Don't instrument clobbers with asan (PR c++/62017)
- Authentication-results: sourceware.org; auth=none
- References: <20140918141246 dot GJ17454 at tucnak dot redhat dot com>
On 09/18/2014 10:12 AM, Jakub Jelinek wrote:
Clobber stmts, being artificial statements, were certainly never
meant to be instrumented. In 4.8 when asan has been introduced into gcc,
the lhs of clobber could be only a decl and as a whole decl store would not
be really instrumented, but with *this clobbers in 4.9 that is no longer the
case.
And this patch fixes the clobber to only clobber the as-base part of the
class, since any virtual bases might not be destroyed yet. This patch
also fixes Jakub's testcase (without his patch).
Tested x86_64-pc-linux-gnu, applying to trunk.
commit e8c36b9fe6c1534925d809a7a15e599770466ee3
Author: Jason Merrill <jason@redhat.com>
Date: Thu Sep 18 11:15:57 2014 -0400
PR c++/62017
* decl.c (begin_destructor_body): Only clobber the as-base part of
*this.
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