re PR sanitizer/64717 (-fsanitize=vptr leads to warning: ‘<anonymous>’ may be used...
authorJakub Jelinek <jakub@gcc.gnu.org>
Thu, 29 Jan 2015 20:40:07 +0000 (21:40 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 29 Jan 2015 20:40:07 +0000 (21:40 +0100)
PR c++/64717
* cp-ubsan.c (cp_ubsan_instrument_vptr): Don't wrap vptr
into SAVE_EXPR.

* g++.dg/ubsan/pr64717-1.C: New test.
* g++.dg/ubsan/pr64717-2.C: New test.

From-SVN: r220262

gcc/cp/ChangeLog
gcc/cp/cp-ubsan.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ubsan/pr64717-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ubsan/pr64717-2.C [new file with mode: 0644]

index 2280e6bd0942f9512adafeebb60f438b7cf876b6..308e5bcc17f345d01b81281c995171e1ab743ac8 100644 (file)
@@ -1,3 +1,9 @@
+2015-01-29  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/64717
+       * cp-ubsan.c (cp_ubsan_instrument_vptr): Don't wrap vptr
+       into SAVE_EXPR.
+
 2015-01-29  Jason Merrill  <jason@redhat.com>
 
        PR c++/49508
index 69e486442fedbe7191c6595147514ec960d8b543..ce12263177077faf895ebf697ac0a76278148975 100644 (file)
@@ -107,7 +107,6 @@ cp_ubsan_instrument_vptr (location_t loc, tree op, tree type, bool is_addr,
                        fold_build2 (NE_EXPR, boolean_type_node, op,
                                     build_zero_cst (TREE_TYPE (op))),
                        vptr, build_int_cst (uint64_type_node, 0));
-  vptr = build1_loc (loc, SAVE_EXPR, uint64_type_node, vptr);
   tree ti_decl = get_tinfo_decl (type);
   mark_used (ti_decl);
   tree ptype = build_pointer_type (type);
index 66a2e2bc1245644c94f64a7cfc8e493e020d590d..d3b38839083bda254c436ec3227cdabc216e0c22 100644 (file)
@@ -1,4 +1,10 @@
-2015-22-01  Uros Bizjak  <ubizjak@gmail.com>
+2015-01-29  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/64717
+       * g++.dg/ubsan/pr64717-1.C: New test.
+       * g++.dg/ubsan/pr64717-2.C: New test.
+
+2015-01-29  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.dg/tree-ssa/pr64801.c: Fix scan-tree-dump-not directive.
 
diff --git a/gcc/testsuite/g++.dg/ubsan/pr64717-1.C b/gcc/testsuite/g++.dg/ubsan/pr64717-1.C
new file mode 100644 (file)
index 0000000..45ed8c6
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/64717
+// { dg-do compile }
+// { dg-options "-O2 -Wuninitialized -fsanitize=vptr" }
+
+class Foo {};
+Foo make_foo ();
+
+struct Handle { virtual ~Handle (); };
+Handle open (Foo);
+
+void
+bar ()
+{
+  Handle file (open (make_foo ())); // { dg-bogus "is used uninitialized" }
+}
diff --git a/gcc/testsuite/g++.dg/ubsan/pr64717-2.C b/gcc/testsuite/g++.dg/ubsan/pr64717-2.C
new file mode 100644 (file)
index 0000000..3f10440
--- /dev/null
@@ -0,0 +1,20 @@
+// PR c++/64717
+// { dg-do compile }
+// { dg-options "-O2 -Wuninitialized -fsanitize=vptr" }
+
+class ios {};
+
+struct stringstream : virtual ios {
+  stringstream (char *);
+  ~stringstream ();
+};
+
+struct string { char *c_str (); };
+
+string make_str ();
+
+void
+bar ()
+{
+  stringstream param (make_str ().c_str ()); // { dg-bogus "is used uninitialized" }
+}