When I changed empty arrays domain to use a signed sizetype [0, -1] domain mangling of a empty-array-type broke because mangling adds an unsigned one to the signed -1 which causes an ICE (I chose to do that instead of shifting the range to [1, 0] because much more code relies on a zero lower bound ...).
The following fixes that by using double-ints for the arithmetic and thus also does not generate a not needed tree node. Bootstrapped and tested on x86_64-unknown-linux-gnu, ok? Thanks, Richard. 2012-06-11 Richard Guenther <rguent...@suse.de> PR c++/53616 * mangle.c (write_array_type): Use double-ints for array domain arithmetic. * g++.dg/ext/pr53605.C: New testcase. 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 { Index: gcc/testsuite/g++.dg/ext/pr53605.C =================================================================== --- gcc/testsuite/g++.dg/ext/pr53605.C (revision 0) +++ gcc/testsuite/g++.dg/ext/pr53605.C (revision 0) @@ -0,0 +1,16 @@ +// { dg-do compile } + +// Avoid -pedantic-error default +// { dg-options "" } + +template <bool lhs_is_null_literal> +class EqHelper { +public: + template <typename T1, typename T2> + static int Compare( const T1& expected, + const T2& actual); +}; +void foo(){ + static const int kData[] = {}; + ::EqHelper<false>::Compare(kData, "abc"); +}