Bug 20693 – align(N): larger than 2^^30 causes unexpected behavior
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-03-23T00:45:40Z
Last change time
2020-03-24T01:46:50Z
Assigned to
No Owner
Creator
Hiroki Noda
Comments
Comment #0 by kubo39 — 2020-03-23T00:45:40Z
Both 2^^30 and 2^^31 are integers positive power of 2, but forbidden.
----
// OK.
align(2 ^^ 30) struct S1 {};
pragma(msg, S1.sizeof); // 1073741824LU
// Error: alignment must be an integer positive power of 2, not -2147483648.
align(2 ^^ 31) struct S2 {};
// Error: alignment must be an integer positive power of 2, not 0.
align(2 ^^ 32) struct S3 {};
---
2^^32 + 1 is not an integer positive power of 2, but allowed.
---
align(2 ^^ 32 + 1) struct S4 {};
pragma(msg, S4.sizeof); // 1LU
----
Comment #1 by kubo39 — 2020-03-24T01:40:29Z
ShlExp also.
----
align(1 << 31) struct S {}; // Error: alignment must be an integer positive power of 2, not -2147483648
----