File force_fit_type.patch of Package gcc41
* stor-layout.c (set_sizetype): Set TYPE_MAX_VALUE properly
for sizetype when sizetype is unsigned.
Index: gcc/stor-layout.c
===================================================================
--- gcc/stor-layout.c.orig 2006-10-09 12:05:44.000000000 +0200
+++ gcc/stor-layout.c 2009-11-20 13:41:21.000000000 +0100
@@ -2033,6 +2033,25 @@ set_sizetype (tree type)
ssizetype = sizetype;
sbitsizetype = bitsizetype;
}
+
+ /* If SIZETYPE is unsigned, we need to fix TYPE_MAX_VALUE so that
+ it is sign extended in a way consistent with force_fit_type. */
+ if (TYPE_UNSIGNED (type))
+ {
+ tree orig_max, new_max;
+
+ orig_max = TYPE_MAX_VALUE (sizetype);
+
+ /* Build a new node with the same values, but a different type. */
+ new_max = build_int_cst_wide (sizetype,
+ TREE_INT_CST_LOW (orig_max),
+ TREE_INT_CST_HIGH (orig_max));
+
+ /* Now sign extend it using force_fit_type to ensure
+ consistency. */
+ new_max = force_fit_type (new_max, 0, 0, 0);
+ TYPE_MAX_VALUE (sizetype) = new_max;
+ }
}
/* TYPE is an integral type, i.e., an INTEGRAL_TYPE, ENUMERAL_TYPE,