diff --git a/compiler/src/dmd/e2ir.d b/compiler/src/dmd/e2ir.d index 7daf061d79..b8c99e6ef1 100644 --- a/compiler/src/dmd/e2ir.d +++ b/compiler/src/dmd/e2ir.d @@ -609,7 +609,8 @@ elem* toElem(Expression e, ref IRState irs) soffset = v.offset; else if (v && v.inAlignSection) { - ethis = el_bin(OPadd, TYnptr, ethis, el_long(TYnptr, fd.salignSection.Soffset)); + const vthisOffset = fd.vthis ? -toSymbol(fd.vthis).Soffset : 0; + ethis = el_bin(OPadd, TYnptr, ethis, el_long(TYnptr, vthisOffset + fd.salignSection.Soffset)); ethis = el_una(OPind, TYnptr, ethis); soffset = v.offset; } @@ -624,10 +625,10 @@ elem* toElem(Expression e, ref IRState irs) if (fd.vthis) { Symbol *vs = toSymbol(fd.vthis); - //printf("vs = %s, offset = %x, %p\n", vs.Sident, cast(int)vs.Soffset, vs); + //printf("vs = %s, offset = x%x, %p\n", vs.Sident.ptr, cast(int)vs.Soffset, vs); soffset -= vs.Soffset; } - //printf("\tSoffset = x%x, sthis.Soffset = x%x\n", s.Soffset, irs.sthis.Soffset); + //printf("\tSoffset = x%x, sthis.Soffset = x%x\n", cast(uint)s.Soffset, cast(uint)irs.sthis.Soffset); } if (!nrvo) diff --git a/compiler/src/dmd/toir.d b/compiler/src/dmd/toir.d index deb19eebdc..2c121e7bf5 100644 --- a/compiler/src/dmd/toir.d +++ b/compiler/src/dmd/toir.d @@ -979,6 +979,7 @@ void buildClosure(FuncDeclaration fd, ref IRState irs) * Reference: * setClosureVarOffset */ +private uint setAlignSectionVarOffset(FuncDeclaration fd) { // Nothing to do diff --git a/compiler/test/runnable/test24184.d b/compiler/test/runnable/test24184.d new file mode 100644 index 0000000000..736824fce8 --- /dev/null +++ b/compiler/test/runnable/test24184.d @@ -0,0 +1,30 @@ +// https://issues.dlang.org/show_bug.cgi?id=24184 + +void stage3(alias abc)(ubyte[]) +{ + bool skipSpaces() + { + abc(); + return false; + } + skipSpaces; +} +ubyte[] singleThreadJsonImpl(alias xxx)(ubyte[] table) +{ + align(64) ubyte[] vector; + + ubyte[] abc() { return vector; } + + stage3!(abc)(table); + + return table; +} +ubyte[] singleThreadJsonText() +{ + bool xxx() { return true; } + + return singleThreadJsonImpl!(xxx)([]); +} +void deserializeJson() { singleThreadJsonText(); } + +void main() { deserializeJson(); }