Bug 5779 – Bad value range propagation for ternary operator

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
Other
OS
Windows
Creation time
2011-03-23T21:24:00Z
Last change time
2011-03-23T21:32:48Z
Assigned to
nobody
Creator
dlang-bugzilla

Comments

Comment #0 by dlang-bugzilla — 2011-03-23T21:24:03Z
void main() { bool b = true; ubyte bit = b ? 1 : 0; } With warnings enabled, the compiler complains: test.d(4): Warning: implicit conversion of expression (b ? 1 : 0) of type int to ubyte can cause loss of data Doesn't happen with D2 (2.052).
Comment #1 by clugdbug — 2011-03-23T21:31:51Z
(In reply to comment #0) > void main() > { > bool b = true; > ubyte bit = b ? 1 : 0; > } > > With warnings enabled, the compiler complains: > > test.d(4): Warning: implicit conversion of expression (b ? 1 : 0) of type int > to ubyte can cause loss of data > > Doesn't happen with D2 (2.052). D1 doesn't have range propagation! It's a D2 feature, which eliminates these kind of nonsense errors. I think this bug is probably invalid.
Comment #2 by dlang-bugzilla — 2011-03-23T21:32:48Z
Oops :) You're probably right.