[Issue 20693] New: align(N): larger than 2^^30 causes unexpected behavior

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 23 00:45:40 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=20693

          Issue ID: 20693
           Summary: align(N): larger than 2^^30 causes unexpected behavior
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: kubo39 at gmail.com

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
----

--


More information about the Digitalmars-d-bugs mailing list