August 23, 2019 [Issue 20154] New: bad closure if local variables have larger alignment requirements | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20154 Issue ID: 20154 Summary: bad closure if local variables have larger alignment requirements Product: D Version: D2 Hardware: x86_64 OS: All Status: NEW Keywords: wrong-code Severity: normal Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: r.sagitario@gmx.de If a local variable has larger alignment requirements, closures that capture function arguments can fail: struct SpinLock { align(64) int x; } void collectReferences(int x) //ref HashTab references) { SpinLock lock; // dmd BUG: alignment causes bad capture! void mark() scope nothrow { assert (x == 7); } mark(); } void main() { collectReferences(7); } For Win64, RSP is aligned according to alignof(SpinLock) for alignments 32-128. This makes the closure offset for the function argument x non-constant. Side note: no alignment happens for align(256) or higher. For Win32, alignment is silently omitted. -- |
Copyright © 1999-2021 by the D Language Foundation