GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
c++

C++: Fix assertion in build_vec_init due to compiler changes

Corrects an assertion in vector initialization code to align with recent compiler optimizations.

This commit adjusts an assertion within GCC’s C++ frontend’s build_vec_init function to prevent an ICE (Internal Compiler Error). Recent compiler changes, particularly an optimization that modifies how cleanups handle rvalues, caused the existing assertion to fail. The patch modifies the assertion to match the new behavior, ensuring compiler stability and correctness during vector initialization, especially with C++ initializer lists.

In Details

The assert(TREE_PURPOSE (cleanup_flags[last]) == rval) in init.cc (build_vec_init) was failing due to compiler changes, specifically r15-6897 and r16-343. The latter optimization changed cleanup handling from setting an iterator to maxindex to clearing rval. This commit adjusts the assertion to expect rval instead of iterator for the TREE_PURPOSE of the last cleanup flag, resolving an ICE for certain initializer list array initializations.

For Context
ICE
Internal Compiler Error. A condition where the compiler encounters an unrecoverable error during its execution, leading to a crash. This typically indicates a bug within the compiler itself.
build_vec_init
A function within GCC's C++ frontend likely responsible for constructing vector (array) initializations, particularly those using initializer lists.
rvalue
In C++, an rvalue represents a temporary value that can be moved from or is the result of an expression. It's distinct from an lvalue, which refers to an object that occupies some identifiable location in memory.
cleanup
In compiler internals, a cleanup refers to a mechanism or code block that releases resources or performs necessary actions when a variable goes out of scope or is no longer needed. This is crucial for managing memory and preventing leaks.
init.cc
A source file in GCC likely related to the initialization of variables and data structures, particularly within the C++ frontend.
Filed Under: c++compiler bugoptimizationice