GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
tree-optimization

Avoid inferring non-null for TARGET_MEM_REF operands

Compiler avoids miscompilation by not assuming memory references are non-null.

The compiler now avoids inferring that the base operand of a TARGET_MEM_REF is non-null. This change corrects a miscompilation in jump-threading optimizations that was triggered by a testcase where a non-null assumption was incorrectly made. The fix adjusts three areas within the compiler’s GIMPLE and range inference passes to take a more conservative stance, particularly for scaled index operands.

In Details

The non_null_loadstore and check_loadstore routines in GIMPLE and range inference are adjusted to avoid inferring non-nullness for the base operand of TARGET_MEM_REF. This is to prevent issues like the one in PR tree-optimization/126658, where jump threading incorrectly assumed the base was dereferenced and thus non-null, leading to miscompilation. The change carves out the common case of scaled indexes, which are unlikely to be actual pointers.

Filed Under: optimizationcompiler