]> git.pld-linux.org Git - packages/gcc.git/blob - gcc-pr22429.patch
- updated to 4.1.0-20051104 (r106487).
[packages/gcc.git] / gcc-pr22429.patch
1 The problem here is fold (build_range_check) converts
2 "-1073741824 <= n && n <= 1073741823" to "n + 1073741824 >= 0"
3 which makes depends on signed overflow being defined.  Fold later converts
4 it to "n >= -1073741824" by my recent patch which is wrong.
5 This patch fixes the problem by using unsigned types if signed overflow
6 is undefined.
7
8 OK? Bootstrapped and tested on x86_64-pc-linux-gnu with no regressions.
9
10 Thanks,
11 Andrew Pinski
12
13         * fold-const.c (build_range_check): Use unsigned when signed
14         overflow is undefined also.  If etype is subtype, make sure that
15         the subtraction is in the supper type.
16
17 --- a/gcc/fold-const.c  2005-10-19 08:15:39.000000000 +0000
18 +++ b/gcc/fold-const.c  2005-10-19 08:29:46.574021728 +0000
19 @@ -4005,7 +4005,8 @@
20      }
21  
22    value = const_binop (MINUS_EXPR, high, low, 0);
23 -  if (value != 0 && TREE_OVERFLOW (value) && ! TYPE_UNSIGNED (etype))
24 +  if (value != 0 && (!flag_wrapv || TREE_OVERFLOW (value))
25 +      && ! TYPE_UNSIGNED (etype))
26      {
27        tree utype, minv, maxv;
28  
29 @@ -4016,6 +4017,11 @@
30         case INTEGER_TYPE:
31         case ENUMERAL_TYPE:
32         case CHAR_TYPE:
33 +         /* There is no requirement that LOW be within the range of ETYPE
34 +            if the latter is a subtype.  It must, however, be within the base
35 +            type of ETYPE.  So be sure we do the subtraction in that type.  */
36 +         if (TREE_TYPE (etype))
37 +           etype = TREE_TYPE (etype);
38           utype = lang_hooks.types.unsigned_type (etype);
39           maxv = fold_convert (utype, TYPE_MAX_VALUE (etype));
40           maxv = range_binop (PLUS_EXPR, NULL_TREE, maxv, 1,
This page took 0.066723 seconds and 3 git commands to generate.