]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR sanitizer/59667 (ubsan: ICE ubsan_type_descriptor)
authorMarek Polacek <polacek@redhat.com>
Wed, 8 Jan 2014 10:06:09 +0000 (10:06 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Wed, 8 Jan 2014 10:06:09 +0000 (10:06 +0000)
PR sanitizer/59667
* ubsan.c (ubsan_type_descriptor): Call strip_array_types on type2.
testsuite/
* c-c++-common/ubsan/pr59667.c: New test.

From-SVN: r206423

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/ubsan/pr59667.c [new file with mode: 0644]
gcc/ubsan.c

index 8888a79ae5b8c8a695f2ba23c043c42d7cf6e00c..5ff7cd027f433b1364222fcbe3ae1fbc7e558bfe 100644 (file)
@@ -1,3 +1,8 @@
+2014-01-08  Marek Polacek  <polacek@redhat.com>
+
+       PR sanitizer/59667
+       * ubsan.c (ubsan_type_descriptor): Call strip_array_types on type2.
+
 2014-01-08  Jakub Jelinek  <jakub@redhat.com>
 
        PR rtl-optimization/59649
index d113f2a09e46e2eba68cc72c1916d04da220e870..f9111f94dba59050216e9f7598d67365e412f5f9 100644 (file)
@@ -1,3 +1,8 @@
+2014-01-08  Marek Polacek  <polacek@redhat.com>
+
+       PR sanitizer/59667
+       * c-c++-common/ubsan/pr59667.c: New test.
+
 2014-01-08  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/59630
diff --git a/gcc/testsuite/c-c++-common/ubsan/pr59667.c b/gcc/testsuite/c-c++-common/ubsan/pr59667.c
new file mode 100644 (file)
index 0000000..367e303
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do run } */
+/* { dg-options "-fsanitize=undefined" } */
+/* { dg-shouldfail "ubsan" } */
+/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
+
+int
+main (void)
+{
+  unsigned int len = 1;
+  float (*P)[len][len] = 0;
+  (*P)[0][0] = 1;
+  return 0;
+}
+
+/* { dg-output "store to null pointer of type 'float'(\n|\r\n|\r)" } */
index 7cc8c180ba83b904b1913a992355fd3bf0672238..1841a947b9c6e3d152685cd8e0bd3cc6030af215 100644 (file)
@@ -311,6 +311,9 @@ ubsan_type_descriptor (tree type, bool want_pointer_type_p)
         type2 = TYPE_METHOD_BASETYPE (type2);
     }
 
+  /* If an array, get its type.  */
+  type2 = strip_array_types (type2);
+
   if (TYPE_NAME (type2) != NULL)
     {
       if (TREE_CODE (TYPE_NAME (type2)) == IDENTIFIER_NODE)