Skip to content

Commit

Permalink
Merge pull request #3797 from yebblies/cppscope
Browse files Browse the repository at this point in the history
[DDMD] Issue 13182 - extern(C++) classes cause crash when allocated on the stack with scope
  • Loading branch information
WalterBright authored and 9rnsr committed Jul 23, 2014
1 parent 118e1a8 commit 7602561
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/declaration.c
Expand Up @@ -2222,6 +2222,12 @@ Expression *VarDeclaration::callScopeDtor(Scope *sc)
*/
//if (cd->isInterfaceDeclaration())
//error("interface %s cannot be scope", cd->toChars());

if (cd->cpp)
{
// Destructors are not supported on extern(C++) classes
break;
}
if (1 || onstack || cd->dtors.dim) // if any destructors
{
// delete this;
Expand Down
12 changes: 12 additions & 0 deletions test/runnable/xtest46.d
Expand Up @@ -3367,6 +3367,17 @@ void test3559()
}
}

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

extern(C++)
class C13182
{
}

void test13182()
{
scope C13182 c = new C13182();
}

/***************************************************/
// 5897
Expand Down Expand Up @@ -7207,6 +7218,7 @@ int main()
test159();
test12824();
test8283();
test13182();
test8395();
test5749();
test8396();
Expand Down

0 comments on commit 7602561

Please sign in to comment.