D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5355 - TLS variables are not 16 byte aligned
Summary: TLS variables are not 16 byte aligned
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2010-12-17 18:36 UTC by Nick Voronin
Modified: 2012-01-20 13:53 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Nick Voronin 2010-12-17 18:36:37 UTC
"Version D 2.007: Data items in static data segment >= 16 bytes in size are now paragraph aligned."

Yet this test shows that neither double[4] nor creal are aligned.

import core.stdc.stdio: printf;

int a;
double[4] d;
creal cr;

void main() {
    printf("%X:%u %X:%u %X:%u\n", &a, (cast(size_t)&a) % 8, &d, (cast(size_t)&d) % 8, &cr, (cast(size_t)&cr) % 8);
}
Comment 1 yebblies 2011-07-03 09:51:34 UTC
Actually, those variables are in tls.  Variables in the static data segment do seem to be 16 byte aligned.

They appear to be all offset from 16 byte alignment by 4 bytes.

Leaving open as this is probably not intended.
Comment 2 Walter Bright 2012-01-20 13:53:24 UTC
TLS segments are now all 16 byte aligned. However, individual variables are aligned based on their type. For example, arrays are aligned based on the alignment requirement of their element type. Arrays of double are aligned on 8 byte boundaries, not 16 bytes.