aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/builtins.c2
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr100576.c12
2 files changed, 14 insertions, 0 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index e1b2848..6a2875e 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -4904,6 +4904,8 @@ check_read_access (tree exp, tree src, tree bound /* = NULL_TREE */,
if (!warn_stringop_overread)
return true;
+ if (bound && !useless_type_conversion_p (size_type_node, TREE_TYPE (bound)))
+ bound = fold_convert (size_type_node, bound);
access_data data (exp, access_read_only, NULL_TREE, false, bound, true);
compute_objsize (src, ost, &data.src);
return check_access (exp, /*dstwrite=*/ NULL_TREE, /*maxread=*/ bound,
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr100576.c b/gcc/testsuite/gcc.c-torture/compile/pr100576.c
new file mode 100644
index 0000000..f2f40ec
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr100576.c
@@ -0,0 +1,12 @@
+/* PR middle-end/100576 */
+
+const char v[] = {0x12};
+
+void
+foo (const char *p)
+{
+ int b = sizeof v;
+ int n = memcmp (p, v, b);
+ if (n)
+ __builtin_abort ();
+}