re PR c/70852 (ice in warn_for_memset)
authorMarek Polacek <polacek@redhat.com>
Fri, 29 Apr 2016 12:39:25 +0000 (12:39 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 29 Apr 2016 12:39:25 +0000 (12:39 +0000)
PR c/70852
* c-common.c (warn_for_memset): Check domain before accessing it.

* gcc.dg/pr70852.c: New test.

From-SVN: r235638

gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr70852.c [new file with mode: 0644]

index f70dc0ea66dd276cbc35543243a11ba7c960d8e4..2a740a57e7bb45da6c18ad413c76edce750d40bb 100644 (file)
@@ -1,3 +1,8 @@
+2016-04-29  Marek Polacek  <polacek@redhat.com>
+
+       PR c/70852
+       * c-common.c (warn_for_memset): Check domain before accessing it.
+
 2016-04-29  Dominik Vogt  <vogt@linux.vnet.ibm.com>
 
        PR/69089
index b2219791881bbb0a742c3501e378b40ffa8c74b1..3c35a6b43530bb4e825d38bad071cd8337174ae4 100644 (file)
@@ -11796,6 +11796,7 @@ warn_for_memset (location_t loc, tree arg0, tree arg2,
          tree elt_type = TREE_TYPE (type);
          tree domain = TYPE_DOMAIN (type);
          if (!integer_onep (TYPE_SIZE_UNIT (elt_type))
+             && domain != NULL_TREE
              && TYPE_MAXVAL (domain)
              && TYPE_MINVAL (domain)
              && integer_zerop (TYPE_MINVAL (domain))
index 93e89d98fb772975d68470a90f2971ec377fab73..3911534c8bb1872cb29ff09edd0a51e443966128 100644 (file)
@@ -3,6 +3,9 @@
        PR sanitizer/70342
        * g++.dg/ubsan/null-7.C: New test.
 
+       PR c/70852
+       * gcc.dg/pr70852.c: New test.
+
 2016-04-29  Dominik Vogt  <vogt@linux.vnet.ibm.com>
 
        PR/69089
diff --git a/gcc/testsuite/gcc.dg/pr70852.c b/gcc/testsuite/gcc.dg/pr70852.c
new file mode 100644 (file)
index 0000000..2dec082
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR c/70852 */
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+
+extern void *memset (void *, int, __SIZE_TYPE__);
+extern int A[];
+void
+fn1 (void)
+{
+  memset (A, 0, 1);
+}