[Issue 2205] New: Warning on comparison between signed and unsigned

Jarrett Billingsley kb3ctd2 at yahoo.com
Tue Jul 8 14:17:41 PDT 2008


<d-bugmail at puremagic.com> wrote in message 
news:bug-2205-3 at http.d.puremagic.com/issues/...
> http://d.puremagic.com/issues/show_bug.cgi?id=2205
>
>           Summary: Warning on comparison between signed and unsigned
>           Product: D
>           Version: unspecified
>          Platform: All
>        OS/Version: All
>            Status: NEW
>          Severity: enhancement
>          Priority: P3
>         Component: DMD
>        AssignedTo: bugzilla at digitalmars.com
>        ReportedBy: o.dathe at gmx.de
>
>
> The following code does not generate a warning when compiled with -w.
>
>  int a=-1;
>  uint b=1;
>  assert (a<b);
>
> The assertion failes since the comparison is done unsigned. I think it is 
> a
> very basic and frequent source of errors and should be taken into account 
> if
> warnings are enabled - just like in gcc -W.

Completely agree.  I can't tell you how many times I've done

for(uint i = x; i >= 0; i--)
    ...

Infinite loop! 




More information about the Digitalmars-d-bugs mailing list