[Issue 259] Comparing signed to unsigned does not generate an error
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Sep 8 10:43:02 PDT 2009
http://d.puremagic.com/issues/show_bug.cgi?id=259
--- Comment #16 from Ellery Newcomer <ellery-newcomer at utulsa.edu> 2009-09-08 10:43:00 PDT ---
Cool. That sounds like a much better solution than the patch I posted.
Concerning my patch, I just realized that comparison with unsigned and zero
generally doesn't make sense either, except maybe
{unsigned} > 0
so now I have
if ( e1->type->isintegral() && e2->type->isintegral()){
if(e1->type->isunsigned() ^ e2->type->isunsigned()){
if(!e1->type->isunsigned() && dynamic_cast<IntegerExp*>(e1)){
sinteger_t v1 = ((sinteger_t) e1->toInteger());
if(v1 > 0) goto JustKidding;
// 0 < uns or 0 !>= uns okay
else if(v1 == 0 && (op == TOKlt || op == TOKul))
goto JustKidding;
}else if(dynamic_cast<IntegerExp*>(e2)){
sinteger_t v2 = ((sinteger_t) e2->toInteger());
if(v2 > 0) goto JustKidding;
// uns > 0 or uns !<= 0 okay
else if(v2 == 0 && (op == TOKgt || op == TOKug))
goto JustKidding;
}
error("comparing signed and unsigned integers");
}
JustKidding:;
}
in case anyone plans to commit it
--
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