Bug 12514 – Value range analysis in triple operator too

Status
RESOLVED
Resolution
WORKSFORME
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-04-03T10:41:00Z
Last change time
2017-07-01T18:50:03Z
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2014-04-03T10:41:04Z
Value range analysis could be extended to cover this case too: void main() { ulong x = 10_000_000; uint y = (x <= uint.max) ? x : 0; } dmd 2.066alpha gives: test.d(3,14): Error: cannot implicitly convert expression (x <= 4294967295LU ? x : 0LU) of type ulong to uint
Comment #1 by yebblies — 2014-04-04T10:17:10Z
This is a long way beyond current VRP.
Comment #2 by dlang-bugzilla — 2017-07-01T18:50:03Z
This is confusing ternary operator VRP with VPR between statements, which is a separate issue and is currently not implemented. VPR within ternary operators seems to work just fine: ubyte y = (1000 <= ubyte.max) ? 1000 : 0;