if (this->next_array > 0) {
arr_live_ranges = new array_live_range[this->next_array];
for (unsigned i = 0; i < this->next_array; ++i)
- arr_live_ranges[i] = array_live_range(i+1, this->array_sizes[i+1]);
+ arr_live_ranges[i] = array_live_range(i+1, this->array_sizes[i]);
}
/* re-calculate arrays */
#if __cplusplus < 201402L
int *idx_map = new int[narrays + 1];
- unsigned *old_sizes = new unsigned[narrays + 1];
+ unsigned *old_sizes = new unsigned[narrays];
#else
unique_ptr<int[]> idx_map = make_unique<int[]>(narrays + 1);
- unique_ptr<unsigned[]> old_sizes = make_unique<unsigned[]>(narrays + 1);
+ unique_ptr<unsigned[]> old_sizes = make_unique<unsigned[]>(narrays);
#endif
memcpy(&old_sizes[0], &array_sizes[0], sizeof(unsigned) * narrays);
int new_narrays = 0;
for (int i = 1; i <= narrays; ++i) {
if (!map[i].is_valid()) {
- ++new_narrays;
- idx_map[i] = new_narrays;
- array_sizes[new_narrays] = old_sizes[i];
+ ++new_narrays;
+ array_sizes[new_narrays-1] = old_sizes[i-1];
+ idx_map[i] = new_narrays;
}
}