diff --git a/src/interpret.c b/src/interpret.c index 365a051242ee..14ec5a1474ed 100644 --- a/src/interpret.c +++ b/src/interpret.c @@ -3027,7 +3027,8 @@ class Interpreter : public Visitor for (size_t i = 0; i < exps->dim; i++) { Expression *ex = (*e->arguments)[i]; - ex = ex->interpret(istate); + if (ex) + ex = ex->interpret(istate); if (exceptionOrCantInterpret(ex)) { result = ex; diff --git a/src/optimize.c b/src/optimize.c index 00752edce2e3..ce7c76343b6f 100644 --- a/src/optimize.c +++ b/src/optimize.c @@ -469,6 +469,8 @@ Expression *Expression_optimize(Expression *e, int result, bool keepLvalue) for (size_t i = 0; i < e->arguments->dim; i++) { Expression *arg = (*e->arguments)[i]; + if (!arg) + continue; arg = arg->optimize(WANTvalue); (*e->arguments)[i] = arg; } diff --git a/test/runnable/structlit.d b/test/runnable/structlit.d index 2130bdd358e0..1622d3a9a3e3 100644 --- a/test/runnable/structlit.d +++ b/test/runnable/structlit.d @@ -853,6 +853,14 @@ void test6937() /********************************************/ // 12681 +struct HasUnion12774 +{ + union + { + int a, b; + } +} + bool test12681() { immutable int x = 42; @@ -881,6 +889,8 @@ bool test12681() assert(s3.p == &x); assert(s3.foo() == 42); + auto x12774 = new HasUnion12774(); + return true; } static assert(test12681());