From 7602561892bf1722f82cdff8f66e7480364b4d82 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Wed, 23 Jul 2014 00:49:20 -0700 Subject: [PATCH] Merge pull request #3797 from yebblies/cppscope [DDMD] Issue 13182 - extern(C++) classes cause crash when allocated on the stack with scope --- src/declaration.c | 6 ++++++ test/runnable/xtest46.d | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/declaration.c b/src/declaration.c index 68809dfaf9f9..c54fb6089008 100644 --- a/src/declaration.c +++ b/src/declaration.c @@ -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; diff --git a/test/runnable/xtest46.d b/test/runnable/xtest46.d index e5629c9ba0b6..d4092e9e56fa 100644 --- a/test/runnable/xtest46.d +++ b/test/runnable/xtest46.d @@ -3367,6 +3367,17 @@ void test3559() } } +/***************************************************/ + +extern(C++) +class C13182 +{ +} + +void test13182() +{ + scope C13182 c = new C13182(); +} /***************************************************/ // 5897 @@ -7207,6 +7218,7 @@ int main() test159(); test12824(); test8283(); + test13182(); test8395(); test5749(); test8396();