[Issue 10749] New: Range value analysis for triple operator too
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Aug 3 03:22:26 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10749
Summary: Range value analysis for triple operator too
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: rejects-valid
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2013-08-03 03:22:23 PDT ---
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).
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list