[Issue 5539] New: Statically disallow unsigned<0 test
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Feb 7 12:24:15 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5539
Summary: Statically disallow unsigned<0 test
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
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 2011-02-07 12:21:53 PST ---
This is a reduced case (Loss of error flag) for a more common bug:
import core.stdc.stdio: printf;
int foo(bool cant_be_true) {
int error = cant_be_true ? -1 : 1;
return error;
}
void main() {
uint x = foo(true);
if (x < 0)
printf("error!");
}
Gerally I suggest to add to the D front-end a test to statically disallow this
kind of test:
unsigned < 0
--
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