From a2d53b285d44f774b3cf892baa69c4a40e60164f Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 10 Feb 1998 16:43:32 -0800 Subject: stor-layout.c (layout_type): Do upper - lower in the native type, so as to properly handle negative indices. * stor-layout.c (layout_type): Do upper - lower in the native type, so as to properly handle negative indices. From-SVN: r17846 --- gcc/stor-layout.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'gcc/stor-layout.c') diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 0e4e508..491af0f 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -786,8 +786,11 @@ layout_type (type) lb, 0)) ub = TREE_OPERAND (ub, 0); + /* The initial subtraction should happen in the original type so + that (possible) negative values are handled appropriately. */ length = size_binop (PLUS_EXPR, size_one_node, - size_binop (MINUS_EXPR, ub, lb)); + fold (build (MINUS_EXPR, TREE_TYPE (lb), + ub, lb))); /* If neither bound is a constant and sizetype is signed, make sure the size is never negative. We should really do this -- cgit v1.1