diff mbox

[committed] Don't instrument clobbers with asan (PR c++/62017)

Message ID 541E3AF9.3010907@redhat.com
State New
Headers show

Commit Message

Jason Merrill Sept. 21, 2014, 2:42 a.m. UTC
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.

Comments

Jakub Jelinek Sept. 21, 2014, 5:12 a.m. UTC | #1
On Sat, Sep 20, 2014 at 10:42:01PM -0400, Jason Merrill wrote:
> 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).

Thanks.

> 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.

	Jakub
diff mbox

Patch

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