Skip to content

Commit

Permalink
Merge pull request #4666 from WalterBright/fix14587
Browse files Browse the repository at this point in the history
fix Issue 14587 - generated 64 bit code for switch jump tables is wrong
  • Loading branch information
andralex committed May 17, 2015
2 parents f02ff58 + 4f77956 commit a7d1edb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/backend/cod3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,8 @@ void doswitch(block *b)
if (vmax - vmin != REGMASK) /* if there is a maximum */
{ /* CMP reg,vmax-vmin */
c = genc2(c,0x81,modregrm(3,7,reg),vmax-vmin);
if (I64)
code_orrex(c, REX_W);
genjmp(c,JA,FLblock,list_block(b->Bsucc)); /* JA default */
}
if (I64)
Expand Down
22 changes: 22 additions & 0 deletions test/runnable/testswitch.d
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,27 @@ void test14352()
assert(transmogrify14352(0) == 10);
}

/*****************************************/
// Issue 14587 - DMD 2.067.1 generating crashing binary on OSX

struct Card {
int value;
int suit;
}

void foo14587(Card card) {
switch(card.value) {
case 4: case 5: case 6: case 11:
break;
default:
}
}

void test14587() {
auto card = Card(11, 1);
foo14587(card);
}

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

int main()
Expand Down Expand Up @@ -687,6 +708,7 @@ int main()
test22();
test23();
test14352();
test14587();

printf("Success\n");
return 0;
Expand Down

0 comments on commit a7d1edb

Please sign in to comment.