]> gcc.gnu.org Git - gcc.git/commitdiff
re PR sanitizer/60569 (Segfault with -flto and -fsanitize=undefined)
authorMarek Polacek <polacek@redhat.com>
Wed, 19 Mar 2014 12:25:04 +0000 (12:25 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Wed, 19 Mar 2014 12:25:04 +0000 (12:25 +0000)
PR sanitizer/60569
* ubsan.c (ubsan_type_descriptor): Check that DECL_NAME is nonnull
before accessing it.
testsuite/
* g++.dg/ubsan/pr60569.C: New test.

From-SVN: r208681

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ubsan/pr60569.C [new file with mode: 0644]
gcc/ubsan.c

index 9b85e2d0824748354c99173a089067daaaea1fdd..3ab789a42a144b4462e10ef9cec2774cd3bd8bff 100644 (file)
@@ -1,3 +1,9 @@
+2014-03-19  Marek Polacek  <polacek@redhat.com>
+
+       PR sanitizer/60569
+       * ubsan.c (ubsan_type_descriptor): Check that DECL_NAME is nonnull
+       before accessing it.
+
 2014-03-19  Richard Biener  <rguenther@suse.de>
 
        PR lto/59543
index 36e53f8c0c20326ab959a3d2917b0d105a08c7f5..9891638a802b5896e2562173b0cff5a62827a200 100644 (file)
@@ -1,3 +1,8 @@
+2014-03-19  Marek Polacek  <polacek@redhat.com>
+
+       PR sanitizer/60569
+       * g++.dg/ubsan/pr60569.C: New test.
+
 2014-03-19  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * gcc.dg/tls/pr58595.c: Require tls_runtime instead of tls.
diff --git a/gcc/testsuite/g++.dg/ubsan/pr60569.C b/gcc/testsuite/g++.dg/ubsan/pr60569.C
new file mode 100644 (file)
index 0000000..df57c06
--- /dev/null
@@ -0,0 +1,21 @@
+// PR sanitizer/60569
+// { dg-do link }
+// { dg-require-effective-target lto }
+// { dg-options "-fsanitize=undefined -flto" }
+
+struct A
+{
+  void foo ();
+  struct
+  {
+    int i;
+    void bar () { i = 0; }
+  } s;
+};
+
+void A::foo () { s.bar (); }
+
+int
+main ()
+{
+}
index 7c7a893aca6495b8b210b3fb5d6efb6c89bffa5c..22470dafeb2d1664312c943ffa5451080114baa8 100644 (file)
@@ -318,7 +318,7 @@ ubsan_type_descriptor (tree type, bool want_pointer_type_p)
     {
       if (TREE_CODE (TYPE_NAME (type2)) == IDENTIFIER_NODE)
        tname = IDENTIFIER_POINTER (TYPE_NAME (type2));
-      else
+      else if (DECL_NAME (TYPE_NAME (type2)) != NULL)
        tname = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type2)));
     }
 
This page took 0.074881 seconds and 5 git commands to generate.