[backport from gcc-4.7/trunk r183213 ] gcc/ 2012-01-16 Jason Merrill PR c++/14179 * vec.c (vec_gc_o_reserve_1): Use ggc_round_alloc_size. --- gcc-4.6.2/gcc/vec.c.~1~ 2011-01-03 21:52:22.000000000 +0100 +++ gcc-4.6.2/gcc/vec.c 2012-01-18 16:15:32.000000000 +0100 @@ -229,6 +229,7 @@ vec_gc_o_reserve_1 (void *vec, int reser { struct vec_prefix *pfx = (struct vec_prefix *) vec; unsigned alloc = calculate_allocation (pfx, reserve, exact); + size_t size; if (!alloc) { @@ -237,7 +238,17 @@ vec_gc_o_reserve_1 (void *vec, int reser return NULL; } - vec = ggc_realloc_stat (vec, vec_offset + alloc * elt_size PASS_MEM_STAT); + /* Calculate the amount of space we want. */ + size = vec_offset + alloc * elt_size; + /* Ask the allocator how much space it will really give us. */ + size = ggc_round_alloc_size (size); + /* Adjust the number of slots accordingly. */ + alloc = (size - vec_offset) / elt_size; + /* And finally, recalculate the amount of space we ask for. */ + size = vec_offset + alloc * elt_size; + + vec = ggc_realloc_stat (vec, size PASS_MEM_STAT); + ((struct vec_prefix *)vec)->alloc = alloc; if (!pfx) ((struct vec_prefix *)vec)->num = 0;