July 20, 2006 [Issue 259] New: Comparing signed to unsigned does not generate an error | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=259 Summary: Comparing signed to unsigned does not generate an error Product: D Version: 0.163 Platform: PC OS/Version: Windows Status: NEW Keywords: spec Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: lio@lunesu.com From the book of Bright, http://www.digitalmars.com/d/expression.html#RelExpression "It is an error to have one operand be signed and the other unsigned for a <, <=, > or >= expression. Use casts to make both operands signed or both operands unsigned." ...yet... #import std.conv; #int main( char[] args[] ) { # int i = toInt(args[1]); # uint u = toUint(args[2]); # if (i < u) # return 1; # else # return 0; #} ...compiled with "dmd", "dmd -debug" or "dmd -release" does not give an error message, neither at compile time, nor at run time. -- |
August 26, 2006 Re: [Issue 259] New: Comparing signed to unsigned does not generate an error | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail Attachments: | d-bugmail@puremagic.com schrieb am 2006-07-20: > http://d.puremagic.com/issues/show_bug.cgi?id=259 > From the book of Bright, http://www.digitalmars.com/d/expression.html#RelExpression > > "It is an error to have one operand be signed and the other unsigned for a <, ><=, > or >= expression. Use casts to make both operands signed or both operands > unsigned." > > ...yet... > > #import std.conv; > #int main( char[] args[] ) { > # int i = toInt(args[1]); > # uint u = toUint(args[2]); > # if (i < u) > # return 1; > # else > # return 0; > #} > > ...compiled with "dmd", "dmd -debug" or "dmd -release" does not give an error message, neither at compile time, nor at run time. Added to DStress as http://dstress.kuehne.cn/nocompile/o/opCmp_08_A.d http://dstress.kuehne.cn/nocompile/o/opCmp_08_B.d http://dstress.kuehne.cn/nocompile/o/opCmp_08_C.d http://dstress.kuehne.cn/nocompile/o/opCmp_08_D.d http://dstress.kuehne.cn/nocompile/o/opCmp_08_E.d http://dstress.kuehne.cn/nocompile/o/opCmp_08_F.d http://dstress.kuehne.cn/nocompile/o/opCmp_08_G.d http://dstress.kuehne.cn/nocompile/o/opCmp_08_H.d http://dstress.kuehne.cn/nocompile/o/opCmp_08_I.d http://dstress.kuehne.cn/nocompile/o/opCmp_08_J.d http://dstress.kuehne.cn/nocompile/o/opCmp_08_K.d http://dstress.kuehne.cn/nocompile/o/opCmp_08_L.d http://dstress.kuehne.cn/nocompile/o/opCmp_08_M.d http://dstress.kuehne.cn/nocompile/o/opCmp_08_N.d http://dstress.kuehne.cn/nocompile/o/opCmp_08_O.d http://dstress.kuehne.cn/nocompile/o/opCmp_08_P.d Thomas |
February 22, 2009 [Issue 259] Comparing signed to unsigned does not generate an error | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=259 smjg@iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |o.dathe@gmx.de ------- Comment #2 from smjg@iname.com 2009-02-22 11:45 ------- *** Bug 2205 has been marked as a duplicate of this bug. *** -- |
February 23, 2009 [Issue 259] Comparing signed to unsigned does not generate an error | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=259 ------- Comment #3 from clugdbug@yahoo.com.au 2009-02-23 02:28 ------- Note that it's critical than any fix for this bug should not make code like the following fail to compile: uint a = 5; if (a > 2) { ... } Otherwise the cure would be worse than the disease <g>. -- |
February 23, 2009 [Issue 259] Comparing signed to unsigned does not generate an error | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=259 ------- Comment #4 from ddparnell@bigpond.com 2009-02-23 02:34 ------- Even more critical, any fix for this bug should not make code like the following fail to compile: uint a = 5; if (a > -2) { ... } -- |
February 23, 2009 [Issue 259] Comparing signed to unsigned does not generate an error | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=259 ------- Comment #5 from 2korden@gmail.com 2009-02-23 07:40 ------- (In reply to comment #4) > Even more critical, any fix for this bug should not make code like the following fail to compile: > > uint a = 5; > if (a > -2) { ... } > Why not? This is obviously a bug! -- |
February 23, 2009 [Issue 259] Comparing signed to unsigned does not generate an error | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=259 ------- Comment #6 from jarrett.billingsley@gmail.com 2009-02-23 07:53 ------- (In reply to comment #5) > > uint a = 5; > > if (a > -2) { ... } > > > > Why not? This is obviously a bug! Agreed. I can't tell you how many times I've done something stupid like: for(uint i = something; i >= 0; i--) { /* yay, infinite loop! */ } A nontrivial condition that always results in an infinite loop should never be accepted. -- |
July 22, 2009 [Issue 259] Comparing signed to unsigned does not generate an error | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=259 Qian Xu <qian.xu@funkwerk-itk.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |qian.xu@funkwerk-itk.com --- Comment #7 from Qian Xu <qian.xu@funkwerk-itk.com> 2009-07-22 00:31:06 PDT --- Is there any official response to this issue? It was reported at 2006, but the status is still "NEW" -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 22, 2009 [Issue 259] Comparing signed to unsigned does not generate an error | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=259 --- Comment #8 from Stewart Gordon <smjg@iname.com> 2009-07-22 01:17:51 PDT --- As I look, bug 2006 doesn't seem to have anything to do with this one at all. But if you find a duplicate of a bug, then mark it as one! -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 22, 2009 [Issue 259] Comparing signed to unsigned does not generate an error | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=259 --- Comment #9 from Qian Xu <qian.xu@funkwerk-itk.com> 2009-07-22 01:34:05 PDT --- (In reply to comment #8) > As I look, bug 2006 doesn't seem to have anything to do with this one at all. > > But if you find a duplicate of a bug, then mark it as one! sorry, i mean it was reported in year 2006. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation