Skip to content

Commit

Permalink
Merge pull request #2865 from yebblies/issue9107
Browse files Browse the repository at this point in the history
Issue 9107 - Value Range Analysis with uint and byte
  • Loading branch information
WalterBright committed Nov 25, 2013
2 parents 4733291 + 3d57417 commit 60441ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/cast.c
Expand Up @@ -145,9 +145,8 @@ MATCH Expression::implicitConvTo(Type *t)
if (type->isintegral() && t->isintegral() &&
type->isTypeBasic() && t->isTypeBasic())
{ IntRange src = this->getIntRange() DUMP;
IntRange targetUnsigned = IntRange::fromType(t, /*isUnsigned*/true) DUMP;
IntRange targetSigned = IntRange::fromType(t, /*isUnsigned*/false) DUMP;
if (targetUnsigned.contains(src) || targetSigned.contains(src))
IntRange target = IntRange::fromType(t) DUMP;
if (target.contains(src))
return MATCHconvert;
}

Expand Down
6 changes: 4 additions & 2 deletions test/compilable/testVRP.d
Expand Up @@ -92,7 +92,8 @@ void modulus_bug6000a() {

void modulus_bug6000b() {
long n = 10520;
ubyte b = n % 10;
ubyte b;
static assert(!__traits(compiles, b = n % 10));
}

void modulus2() {
Expand All @@ -110,7 +111,8 @@ void modulus3() {
void modulus4() {
uint i;
ushort s;
short t = i % s;
short t;
static assert(!__traits(compiles, t = i % s));
}

void modulusFail() {
Expand Down

0 comments on commit 60441ae

Please sign in to comment.