You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
bugzilla (@WalterBright) commented on 2020-08-09T03:35:55Z
The alignment code is emitted for Win64, but not for Win32. But you listed the bug applying to x86_64.
So please clarify:
Is this working for 64 bit platforms?
bugzilla (@WalterBright) commented on 2020-08-09T03:42:43Z
Currently, stack alignment is enforced only for 64 bit compilations and 32 bit OSX compilations. See the setting of `enforcealign` in codgen() in cgcod.d.
(In reply to Walter Bright from comment #1)
> The alignment code is emitted for Win64, but not for Win32. But you listed> the bug applying to x86_64.
Win32 passes the assert, but ignores alignments.
> > So please clarify:> > Is this working for 64 bit platforms?
No.
Rainer Schuetze (@rainers) reported this on 2019-08-23T09:35:35Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=20154
CC List
Description
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.The text was updated successfully, but these errors were encountered: