[Issue 3173] ICE(mtype.c) on wrong code (double to long to int conversion)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 31 23:56:39 PDT 2009


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


Don <clugdbug at yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
         OS/Version|Linux                       |All




--- Comment #2 from Don <clugdbug at yahoo.com.au>  2009-08-31 23:56:38 PDT ---

Cause: default case for getIntRange() assumes it's an integer, which isn't true
if there's casting.
Solution: if not an integer, assume it could contain anything.

PATCH: cast.c, line 1902 (in Walter's private beta of DMD2.032):

IntRange Expression::getIntRange()
{
    IntRange ir;
    ir.imin = 0;
    if (type->isintegral())
    ir.imax = type->sizemask();
    else
    ir.imax = 0xFFFFFFFFFFFFFFFFULL; // assume the worst
    return ir;
}

===========
TEST CASES FOR TEST SUITE
===========

struct S3173{
   double z;
}

int bug3173(int x) {  return x; }

S3173 s3173;
double e3173 = 4;
const double d3173 = 4;
// invalid, but should not ICE

static assert(!is(typeof(bug3173(cast(long)e3173))));
static assert(!is(typeof(bug3173(cast(long)s3173))));
static assert(!is(typeof(bug3173(cast(long)3.256679e30))));
// And two valid cases:
static assert(is(typeof(bug3173(cast(long)d3173))));
static assert(is(typeof(bug3173(cast(long)3.256679e4))));

-- 
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