digitalmars.D.bugs - [Issue 2205] New: Warning on comparison between signed and unsigned
- d-bugmail puremagic.com (20/20) Jul 08 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2205
- Jarrett Billingsley (6/27) Jul 08 2008 Completely agree. I can't tell you how many times I've done
- d-bugmail puremagic.com (13/13) Jul 08 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2205
- d-bugmail puremagic.com (11/11) Feb 22 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2205
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 digitalmars.com ReportedBy: o.dathe 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. --
Jul 08 2008
<d-bugmail puremagic.com> wrote in message news:bug-2205-3 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 digitalmars.com ReportedBy: o.dathe 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!
Jul 08 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2205 smjg iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smjg iname.com Keywords| |diagnostic I'd like this to either: - be an error - promote both sides to long - generate some code resembling assert (a < 0 || cast(uint) a < b); --
Jul 08 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2205 smjg iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Keywords|diagnostic |accepts-invalid Resolution| |DUPLICATE I've just checked, and by spec it's supposed to be an error. *** This bug has been marked as a duplicate of 259 *** --
Feb 22 2009