www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5539] New: Statically disallow unsigned<0 test

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: bearophile_hugs eml.cc



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: -------
Feb 07 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5539


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |DUPLICATE



09:19:32 PST ---
*** This issue has been marked as a duplicate of issue 6949 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 18 2012