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

ranger: Fix operator_div with VREL_LT

Corrects range analysis for division operations involving negative numbers.

A bug in the ranger pass’s handling of division (operator_div) with a varying lower bound (VREL_LT) has been fixed. Previously, if the range was not explicitly set to zero, it could become undefined, leading to incorrect intersection calculations. The fix ensures that if either operand is negative, the division result is handled correctly, preventing undefined behavior and passing a new test case.

In Details

The operator_div::op1_op2_relation_effect in the ranger pass incorrectly handled cases where rel_range was not initialized to zero and VREL_LT was involved. This resulted in the lhs becoming undefined when intersected with such a range. The fix introduces an early return if either operand's range is not non-negative, ensuring correct range propagation for division.

For Context
ranger
A GCC optimization pass that analyzes and propagates information about the possible ranges of variables.
VREL_LT
Likely a value within the ranger pass indicating a 'varying less than' relationship for a variable's range.
operator_div
Represents a division operation within GCC's intermediate representation, analyzed by the ranger pass.
undefined behavior
Program behavior that results from an implementation not being specified by the C++ standard. It can range from incorrect results to crashes.
Filed Under: optimizationbugfixrange analysis