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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Sep 8 09:40:33 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=259



--- Comment #15 from Don <clugdbug at yahoo.com.au> 2009-09-08 09:40:30 PDT ---
(In reply to comment #14)
> Okay, so what I have is it checks for 
[snip]
> 
> signed cmp unsigned 
> 
> or vice versa is okay if the signed arg is a literal and its value is
> nonnegative. 

In D2, it's possible to a lot better than this. With the new D2 rules for
implicit conversion between integral types (range-based), it should be enough
to require that one of the types must implicitly convert to the other. This
doesn't quite work yet, since range-based addition (for example) is not yet
implemented.
This will mean that stuff like:
byte b;
uint u;
b = -67;
if (u < b + 0x100) ...
is OK because although b + 0x100 is signed, it can never be less than 1, so it
can safely be converted to unsigned.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list