[Issue 259] New: Comparing signed to unsigned does not generate an error

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jul 20 04:35:00 PDT 2006


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 at digitalmars.com
        ReportedBy: lio at 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.


-- 




More information about the Digitalmars-d-bugs mailing list