From becd62f2b25f5b1aed27c10e82276c0335868a77 Mon Sep 17 00:00:00 2001 From: k-hara Date: Tue, 9 Dec 2014 14:32:24 +0900 Subject: [PATCH] fix Issue 13835 - ICE in interpret.c:736 - Issue with static variables --- src/interpret.c | 7 ++----- test/fail_compilation/ice13835.d | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 test/fail_compilation/ice13835.d diff --git a/src/interpret.c b/src/interpret.c index dd8830a20ab7..b06399f73b22 100644 --- a/src/interpret.c +++ b/src/interpret.c @@ -5965,13 +5965,10 @@ class Interpreter : public Visitor StructLiteralExp *se = (StructLiteralExp *)ex; dinteger_t offset = ae->e2->toInteger(); result = se->getField(e->type, (unsigned)offset); - if (!result) - result = CTFEExp::cantexp; - return; + if (result) + return; } } - result = Ptr(e->type, e->e1).copy(); - return; } // Check for .classinfo, which is lowered in the semantic pass into **(class). diff --git a/test/fail_compilation/ice13835.d b/test/fail_compilation/ice13835.d new file mode 100644 index 000000000000..d07d7add4597 --- /dev/null +++ b/test/fail_compilation/ice13835.d @@ -0,0 +1,22 @@ +/* +TEST_OUPUT: +--- +fail_compilation/ice13835.d(15): Error: value of 'this' is not known at compile time +fail_compilation/ice13835.d(21): Error: template instance ice13835.Foo!int error instantiating +--- +*/ + +class Foo(T) +{ + private T* _data; + + final private void siftUp(int position) nothrow + { + static T crash = *(this._data + position); + } +} + +void main() +{ + auto heap = new Foo!(int); +}