[Issue 20154] New: bad closure if local variables have larger alignment requirements
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Aug 23 09:35:35 UTC 2019
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 at puremagic.com
Reporter: r.sagitario at 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.
--
More information about the Digitalmars-d-bugs
mailing list