aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index ad4770b..3d63836 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -4133,7 +4133,11 @@ decode_field_reference (location_t loc, tree *exp_, HOST_WIDE_INT *pbitsize,
punsignedp, preversep, pvolatilep);
if ((inner == exp && and_mask == 0)
|| *pbitsize < 0 || offset != 0
- || TREE_CODE (inner) == PLACEHOLDER_EXPR)
+ || TREE_CODE (inner) == PLACEHOLDER_EXPR
+ /* Reject out-of-bound accesses (PR79731). */
+ || (! AGGREGATE_TYPE_P (TREE_TYPE (inner))
+ && compare_tree_int (TYPE_SIZE (TREE_TYPE (inner)),
+ *pbitpos + *pbitsize) < 0))
return 0;
*exp_ = exp;