Bug 10749 – Range value analysis for triple operator too

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-08-03T03:22:23Z
Last change time
2024-12-13T18:10:00Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: dmd#18641 →

Comments

Comment #0 by bearophile_hugs — 2013-08-03T03:22:23Z
void main() { uint x = 6; char digit1 = (x % 10) + '0'; // OK char digit2 = (x < 10) ? (x + '0') : '#'; // Error. } DMD 2.064alpha gives: test.d(4): Error: cannot implicitly convert expression (x < 10u ? x + 48u : 35u) of type uint to char I think the line with digit2 should compile. (Every useless cast removed from the code reduces the chance of bugs).
Comment #1 by robert.schadek — 2024-12-13T18:10:00Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18641 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB