[Issue 13244] Wrong code with -inline and foreach/map/all
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Jul 2 22:49:36 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=13244
--- Comment #5 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to Kenji Hara from comment #4)
> Reduced case in comment #1 does not reproduce segfault with 2.068 git-head.
OK, I confirmed that the original issue might be a dup of issue 14366, but that
fix (#PR 4505) had contained problem.
void ToElemVisitor::visit(DotVarExp *) in e2ir.c
elem *e = toElem(dve->e1, irs);
Type *tb1 = dve->e1->type->toBasetype();
if (tb1->ty != Tclass && tb1->ty != Tpointer)
e = addressElem(e, tb1);
e = el_bin(OPadd, TYnptr, e, el_long(TYsize_t, v->offset));
if (v->isRef() || v->isOut()) // 14366 fix
e = el_una(OPind, TYptr, e); // Line 3367
e = el_una(OPind, totym(dve->type), e);
if (tybasic(e->Ety) == TYstruct)
{
e->ET = Type_toCtype(dve->type);
}
el_setLoc(e,dve->loc);
result = e;
At the line 3367, the indirection result is typed as TYptr - it's wrong. In
32bit/64 code gen, we should use TYnptr.
By the difference, the indirection result will be stored in 16bit size
register, and then the corrupted pointer will cause Access Violation.
--
More information about the Digitalmars-d-bugs
mailing list