http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53605
Richard Guenther <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org --- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-06-11 10:37:50 UTC --- Empty arrays have a signed domain with [0, -1] range. So write_array_type has to be adjusted to Index: gcc/cp/mangle.c =================================================================== --- gcc/cp/mangle.c (revision 188384) +++ gcc/cp/mangle.c (working copy) @@ -3119,7 +3119,8 @@ write_array_type (const tree type) { /* The ABI specifies that we should mangle the number of elements in the array, not the largest allowed index. */ - max = size_binop (PLUS_EXPR, max, size_one_node); + max = size_binop (PLUS_EXPR, max, + build_int_cst (TREE_TYPE (max), 1)); write_unsigned_number (tree_low_cst (max, 1)); } else or Index: gcc/cp/mangle.c =================================================================== --- gcc/cp/mangle.c (revision 188384) +++ gcc/cp/mangle.c (working copy) @@ -3119,8 +3119,10 @@ write_array_type (const tree type) { /* The ABI specifies that we should mangle the number of elements in the array, not the largest allowed index. */ - max = size_binop (PLUS_EXPR, max, size_one_node); - write_unsigned_number (tree_low_cst (max, 1)); + double_int dmax + = double_int_add (tree_to_double_int (max), double_int_one); + gcc_assert (double_int_fits_in_uhwi_p (dmax)); + write_unsigned_number (dmax.low); } else { but I wonder about the inconsistency between the max == INTEGER_CST and !INTEGER_CST case where we do _not_ add one to the expression to be mangled. I'll give the double-int variant testing.