Skip to content

Commit

Permalink
fix Issue 10642 - Win64: wrong codegen comparing different sized inte…
Browse files Browse the repository at this point in the history
…ger arguments
  • Loading branch information
WalterBright committed Jul 16, 2013
1 parent 70cc17d commit 439e85a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/backend/cod3.c
Expand Up @@ -3591,6 +3591,8 @@ code* prolog_loadparams(tym_t tyf, bool pushalloc, regm_t* namedargs)
c2->Iflags |= CFopsize; // operand size
if (I64 && sz >= REGSIZE)
c2->Irex |= REX_W;
if (I64 && sz == 1 && s->Sreglsw >= 4)
c2->Irex |= REX;
if (!hasframe)
{ /* Convert to ESP relative address rather than EBP */
assert(!I16);
Expand Down
45 changes: 45 additions & 0 deletions test/runnable/test42.d
Expand Up @@ -5750,6 +5750,50 @@ void test10633()
assert(tod._seconds == 59);
}

/***************************************************/

import std.stdio;

void _assertEq (ubyte lhs, short rhs, string msg, string file, size_t line)
{
immutable result = lhs == rhs;

if(!result)
{
string op = "==";
if(msg.length > 0)
writefln(`_assertEq failed: [%s] is not [%s].`, lhs, rhs);
else
writefln(`_assertEq failed: [%s] is not [%s]: %s`, lhs, rhs, msg);
}

assert(result);
}

struct Date
{
short year;
ubyte month;
ubyte day;
}

struct MonthDay
{
ubyte month;
short day;
}

void test10642()
{
static void test(Date date, int day, MonthDay expected, size_t line = __LINE__)
{
_assertEq(date.day, expected.day, "", __FILE__, line);
}

test(Date(1999, 1, 1), 1, MonthDay(1,1));
}


/***************************************************/

int main()
Expand Down Expand Up @@ -6038,6 +6082,7 @@ int main()
test4414();
test9844();
test10633();
test10642();

writefln("Success");
return 0;
Expand Down

0 comments on commit 439e85a

Please sign in to comment.