aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ipa-cp.cc4
-rw-r--r--gcc/testsuite/c-c++-common/pr108605.c24
2 files changed, 27 insertions, 1 deletions
diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index 826bbc6..4b8dedc 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -1982,7 +1982,9 @@ ipa_agg_value_from_jfunc (ipa_node_params *info, cgraph_node *node,
tree value = NULL_TREE;
int src_idx;
- if (item->offset < 0 || item->jftype == IPA_JF_UNKNOWN)
+ if (item->offset < 0
+ || item->jftype == IPA_JF_UNKNOWN
+ || item->offset >= (HOST_WIDE_INT) UINT_MAX * BITS_PER_UNIT)
return NULL_TREE;
if (item->jftype == IPA_JF_CONST)
diff --git a/gcc/testsuite/c-c++-common/pr108605.c b/gcc/testsuite/c-c++-common/pr108605.c
new file mode 100644
index 0000000..418b37d
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr108605.c
@@ -0,0 +1,24 @@
+/* PR ipa/108605 */
+/* { dg-do compile { target { lp64 || llp64 } } } */
+/* { dg-options "-O2" } */
+
+struct S {
+ char a, b, c;
+ int d[__INT_MAX__], e;
+};
+
+void
+foo (struct S *s)
+{
+ if (s->b && s->c != 0)
+ __builtin_abort ();
+}
+
+void
+bar (void)
+{
+ struct S s[2];
+ s[0].a = 0;
+ s[0].e = 0;
+ foo (s);
+}