GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
gcc/tree-optimization

tree-optimization/126150 - Fix ICE with replace_uses_by by deferring EH edge purging

Fixes a compiler internal error occurring during use replacement by deferring EH edge purging.

This commit resolves an internal compiler error (ICE) in the replace_uses_by function that occurred when removing basic blocks. The issue stemmed from attempting to purge EH (Exception Handling) edges while iterating over the statements that defined the uses. The fix defers the purging of EH edges until after the iteration is complete, preventing the invalidation of data structures during processing.

In Details

PR tree-optimization/126150 revealed an ICE in tree-cfg.cc's replace_uses_by. The problem arises because EH edge purging, which can remove basic blocks, is triggered within a FOR_EACH_IMM_USE_STMT loop. This loop iterates over uses that might be in basic blocks subsequently removed, leading to use-after-free or similar issues. The fix defers the EH edge purging to occur after the loop finishes, ensuring the integrity of the iteration.

For Context
ICE
Internal Compiler Error. A crash within the compiler itself, usually indicating a bug in the compiler's logic rather than the user's code.
EH edge
An edge in the control flow graph (CFG) representing an exception handling path. These edges connect code blocks that might throw an exception to the corresponding exception handlers.
basic block
A sequence of instructions with a single entry point and a single exit point. Control flow graphs are composed of basic blocks.
Filed Under: optimizationbugfix