You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem or challenge?
Integer widening casts currently leave unbounded interval endpoints unbounded in the destination type. This loses useful information: an unbounded UInt32 interval cast to Int64 still represents values in [0, 4294967295]. Preserving those limits lets interval analysis prove that subsequent arithmetic is safe and retain valid optimizations.
PR #25234 explored preserving these bounds, but the change exposed existing interval-bound failures in negation and narrowing casts during merge-queue testing:
Negation does not correctly handle a concrete signed minimum such as i32::MIN.
Narrowing casts can fail on inferred interval endpoints even when the actual input values fit in the destination type.
Previously, those endpoints remained unbounded, so these paths did not encounter the concrete limits. The review agreed to defer widening to a separate change so that the overflow and division correctness fixes could remain focused.
Describe the solution you'd like
Preserve source-type limits when widening integer intervals, together with the boundary handling needed to use those limits safely downstream.
Materialize source-type minima and maxima for unbounded endpoints when the destination integer type can represent the entire source domain. Preserve existing finite bounds.
Handle negation at signed minima conservatively and consistently with runtime arithmetic semantics.
Handle narrowing of inferred bounds without rejecting valid queries solely because an estimated endpoint is out of range. Preserve runtime cast semantics and do not exclude values that can occur at execution time.
Add targeted coverage for fully and partially unbounded widening casts, signed/unsigned type transitions, negation at signed extrema, and subsequent narrowing at both endpoints. Include composed expressions that exercise these transitions, the affected SQLite regressions, and the FIFO and sort cases from #25234 that motivated preserving source bounds.
Describe alternatives you've considered
Keep widening casts conservative by leaving unbounded endpoints unbounded. This avoids exposing the boundary-handling gaps, but loses opportunities to prove arithmetic safe.
Is your feature request related to a problem or challenge?
Integer widening casts currently leave unbounded interval endpoints unbounded in the destination type. This loses useful information: an unbounded
UInt32interval cast toInt64still represents values in[0, 4294967295]. Preserving those limits lets interval analysis prove that subsequent arithmetic is safe and retain valid optimizations.PR #25234 explored preserving these bounds, but the change exposed existing interval-bound failures in negation and narrowing casts during merge-queue testing:
i32::MIN.Previously, those endpoints remained unbounded, so these paths did not encounter the concrete limits. The review agreed to defer widening to a separate change so that the overflow and division correctness fixes could remain focused.
Describe the solution you'd like
Preserve source-type limits when widening integer intervals, together with the boundary handling needed to use those limits safely downstream.
Add targeted coverage for fully and partially unbounded widening casts, signed/unsigned type transitions, negation at signed extrema, and subsequent narrowing at both endpoints. Include composed expressions that exercise these transitions, the affected SQLite regressions, and the FIFO and sort cases from #25234 that motivated preserving source bounds.
Describe alternatives you've considered
Keep widening casts conservative by leaving unbounded endpoints unbounded. This avoids exposing the boundary-handling gaps, but loses opportunities to prove arithmetic safe.
Additional context
No response