Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gen/toir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2095,15 +2095,15 @@ class ToElemVisitor : public Visitor {

p->ir->SetInsertPoint(condtrue);
PGO.emitCounterIncrement(e);
DValue *u = toElem(e->e1);
DValue *u = toElemDtor(e->e1);
if (retPtr && u->type->toBasetype()->ty != TY::Tnoreturn) {
LLValue *lval = makeLValue(e->loc, u);
DtoStore(lval, DtoBitCast(retPtr, lval->getType()->getPointerTo()));
}
llvm::BranchInst::Create(condend, p->scopebb());

p->ir->SetInsertPoint(condfalse);
DValue *v = toElem(e->e2);
DValue *v = toElemDtor(e->e2);
if (retPtr && v->type->toBasetype()->ty != TY::Tnoreturn) {
LLValue *lval = makeLValue(e->loc, v);
DtoStore(lval, DtoBitCast(retPtr, lval->getType()->getPointerTo()));
Expand Down
11 changes: 11 additions & 0 deletions tests/codegen/gh4570.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: %ldc -c %s

struct S {
~this() {}
}

int foo(S[] ss...) { return 0; }

void bar(bool a) {
const r = a ? foo(S()) : foo(S());
}