This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH to fix ICE with -Wint-conversion (PR middle-end/86202)
- From: Marek Polacek <polacek at redhat dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 18 Jun 2018 16:34:57 -0400
- Subject: PATCH to fix ICE with -Wint-conversion (PR middle-end/86202)
This patch improves the checks in size_must_be_zero_p so that we don't
call get_range_info with SIZE of a pointer type.
Bootstrapped/regtested on x86_64-linux, ok for trunk and 8?
2018-06-18 Marek Polacek <polacek@redhat.com>
PR middle-end/86202
* gimple-fold.c (size_must_be_zero_p): Check the type of the size.
* gcc.dg/Wint-conversion-2.c: New test.
diff --git gcc/gimple-fold.c gcc/gimple-fold.c
index a01bce7ab08..e97e8c74308 100644
--- gcc/gimple-fold.c
+++ gcc/gimple-fold.c
@@ -646,7 +646,7 @@ size_must_be_zero_p (tree size)
if (integer_zerop (size))
return true;
- if (TREE_CODE (size) != SSA_NAME)
+ if (TREE_CODE (size) != SSA_NAME || !INTEGRAL_TYPE_P (TREE_TYPE (size)))
return false;
wide_int min, max;
diff --git gcc/testsuite/gcc.dg/Wint-conversion-2.c gcc/testsuite/gcc.dg/Wint-conversion-2.c
index e69de29bb2d..0c9dac44c41 100644
--- gcc/testsuite/gcc.dg/Wint-conversion-2.c
+++ gcc/testsuite/gcc.dg/Wint-conversion-2.c
@@ -0,0 +1,11 @@
+/* PR middle-end/86202 */
+/* { dg-do compile } */
+/* { dg-options "-Wint-conversion" } */
+
+void *memcpy (void *, void *, __SIZE_TYPE__ *);
+void *a, *b;
+void f (void)
+{
+ long unsigned int c = 0;
+ memcpy (a, b, c); /* { dg-warning "passing argument" } */
+}
Marek