Skip to content

Commit

Permalink
Merge pull request #3257 from WalterBright/fix12044
Browse files Browse the repository at this point in the history
fix Issue 12044 - Invalid code gen causes segfault
  • Loading branch information
9rnsr committed Feb 15, 2014
1 parent 3e79f51 commit a822cc5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/mtype.c
Expand Up @@ -2428,6 +2428,8 @@ Identifier *Type::getTypeInfoIdent(int internal)
if (ty == Tarray)
buf.writeByte(mangleChar[((TypeArray *)this)->next->ty]);
}
else if (deco)
buf.writestring(deco);
else
toDecoBuffer(&buf);

Expand All @@ -2441,7 +2443,7 @@ Identifier *Type::getTypeInfoIdent(int internal)
assert(name);

sprintf(name, "_D%lluTypeInfo_%s6__initZ", (unsigned long long) 9 + len, buf.data);
//printf("name = %s\n", name);
//printf("%p, deco = %s, name = %s\n", this, deco, name);
assert(strlen(name) < namelen); // don't overflow the buffer

size_t off = 0;
Expand Down
27 changes: 27 additions & 0 deletions test/runnable/xtest46.d
Expand Up @@ -6881,6 +6881,32 @@ void test11317()

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

struct S12044(T)
{
void f()()
{
new T[1];
}

bool opEquals(O)(O)
{
f();
}
}

void test12044()
{
()
{
enum E { e }
auto arr = [E.e];
S12044!E s;
}
();
}

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

int main()
{
test1();
Expand Down Expand Up @@ -7164,6 +7190,7 @@ int main()
test7254();
test11075();
test11317();
test12044();

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

0 comments on commit a822cc5

Please sign in to comment.