From 1c8305dbf70dafb1528b73c317108fb2901eb604 Mon Sep 17 00:00:00 2001 From: k-hara Date: Wed, 9 Jan 2013 16:43:07 +0900 Subject: [PATCH] fix Issue 9284 - DMD segfaults with templated ctors in constructor delegation --- src/expression.c | 2 ++ test/fail_compilation/ice9284.d | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 test/fail_compilation/ice9284.d diff --git a/src/expression.c b/src/expression.c index b8b4f2437049..f27e63266f14 100644 --- a/src/expression.c +++ b/src/expression.c @@ -8334,6 +8334,8 @@ Expression *CallExp::semantic(Scope *sc) } f = resolveFuncCall(sc, loc, cd->ctor, NULL, NULL, arguments, 0); + if (!f) + return new ErrorExp(); checkDeprecated(sc, f); #if DMDV2 checkPurity(sc, f); diff --git a/test/fail_compilation/ice9284.d b/test/fail_compilation/ice9284.d new file mode 100644 index 000000000000..b9e44da727de --- /dev/null +++ b/test/fail_compilation/ice9284.d @@ -0,0 +1,22 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/ice9284.d(15): Error: template ice9284.C.__ctor does not match any function template declaration. Candidates are: +fail_compilation/ice9284.d(13): ice9284.C.__ctor()(string) +fail_compilation/ice9284.d(15): Error: template ice9284.C.__ctor()(string) cannot deduce template function from argument types !()(int) +fail_compilation/ice9284.d(21): Error: template instance ice9284.C.__ctor!() error instantiating +--- +*/ + +class C +{ + this()(string) + { + this(10); + // delegating to a constructor which not exists. + } +} +void main() +{ + new C("hello"); +}