diff mbox

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

Message ID 20140918141246.GJ17454@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Sept. 18, 2014, 2:12 p.m. UTC
Hi!

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.

Fixed thusly, tested on x86_64-linux, committed to trunk and 4.9 as obvious.

2014-09-18  Jakub Jelinek  <jakub@redhat.com>

	PR c++/62017
	* asan.c (transform_statements): Don't instrument clobber statements.

	* g++.dg/asan/pr62017.C: New test.


	Jakub
diff mbox

Patch

--- gcc/asan.c.jj	2014-09-08 22:12:52.000000000 +0200
+++ gcc/asan.c	2014-09-18 14:34:30.023446693 +0200
@@ -2072,6 +2072,7 @@  transform_statements (void)
 	  if (has_stmt_been_instrumented_p (s))
 	    gsi_next (&i);
 	  else if (gimple_assign_single_p (s)
+		   && !gimple_clobber_p (s)
 		   && maybe_instrument_assignment (&i))
 	    /*  Nothing to do as maybe_instrument_assignment advanced
 		the iterator I.  */;
--- gcc/testsuite/g++.dg/asan/pr62017.C.jj	2014-09-18 14:44:03.964525585 +0200
+++ gcc/testsuite/g++.dg/asan/pr62017.C	2014-09-18 14:43:52.000000000 +0200
@@ -0,0 +1,17 @@ 
+// PR c++/62017
+// { dg-do run }
+
+struct A
+{
+  int x;
+  virtual ~A () {}
+};
+struct B : public virtual A {};
+struct C : public virtual A {};
+struct D : public B, virtual public C {};
+
+int
+main ()
+{
+  D d;
+}