Bug 5539 – Statically disallow unsigned<0 test

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-02-07T12:21:00Z
Last change time
2012-12-18T09:19:32Z
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2011-02-07T12:21:53Z
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
Comment #1 by andrej.mitrovich — 2012-12-18T09:19:32Z
*** This issue has been marked as a duplicate of issue 6949 ***