D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20693 - align(N): larger than 2^^30 causes unexpected behavior
Summary: align(N): larger than 2^^30 causes unexpected behavior
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-23 00:45 UTC by Hiroki Noda
Modified: 2020-03-24 01:46 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Hiroki Noda 2020-03-23 00:45:40 UTC
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 Hiroki Noda 2020-03-24 01:40:29 UTC
ShlExp also.

----
align(1 << 31) struct S {};  // Error: alignment must be an integer positive power of 2, not -2147483648
----
Comment 2 Hiroki Noda 2020-03-24 01:46:50 UTC
Ahh, I got it. this is not a bug.