Bug 5528 – Some integer interval analysis to avoid some casts

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-02-05T06:07:00Z
Last change time
2011-06-16T01:01:05Z
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2011-02-05T06:07:05Z
This little D2 program shows code that's correct: void main() { uint i = 10; ubyte x1 = i % ubyte.max; ulong l = 10; uint x2 = l % uint.max; } But dmd 2.051 asks for casts: test.d(3): Error: cannot implicitly convert expression (i % 255u) of type uint to ubyte test.d(5): Error: cannot implicitly convert expression (l % 4294967295LU) of type ulong to uint I think those casts are not necessary, so I'd like dmd to avoid asking for casts in such situations.
Comment #1 by yebblies — 2011-06-16T01:01:05Z
*** This issue has been marked as a duplicate of issue 3147 ***