August 03, 2013 [Issue 10749] New: Range value analysis for triple operator too | ||||
---|---|---|---|---|
| ||||
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@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@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: ------- |
Copyright © 1999-2021 by the D Language Foundation