Thread overview | ||||||
---|---|---|---|---|---|---|
|
July 08, 2008 [Issue 2205] New: Warning on comparison between signed and unsigned | ||||
---|---|---|---|---|
| ||||
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. -- |
July 08, 2008 Re: [Issue 2205] New: Warning on comparison between signed and unsigned | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | <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! |
July 09, 2008 [Issue 2205] Warning on comparison between signed and unsigned | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2205 smjg@iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smjg@iname.com Keywords| |diagnostic ------- Comment #1 from smjg@iname.com 2008-07-08 19:48 ------- 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); -- |
February 22, 2009 [Issue 2205] Warning on comparison between signed and unsigned | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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 ------- Comment #2 from smjg@iname.com 2009-02-22 11:45 ------- I've just checked, and by spec it's supposed to be an error. *** This bug has been marked as a duplicate of 259 *** -- |
Copyright © 1999-2021 by the D Language Foundation