Bug 22858 – [REG2.099] Incorrect alignment of void*[0]

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-03-07T22:52:27Z
Last change time
2022-03-27T02:24:28Z
Keywords
industry, pull, wrong-code
Assigned to
No Owner
Creator
johanengelen

Comments

Comment #0 by johanengelen — 2022-03-07T22:52:27Z
Testcase: ``` struct S { int a; void*[0] arr; } static assert (S.arr.offsetof % size_t.sizeof == 0); // aligned pointer? ``` Alignment is correct for 2.097, but is incorrect for 2.099. (Tested with LDC 1.27 and 1.29-beta). Could be a regression of 2.098 or 2.099.
Comment #1 by moonlightsentinel — 2022-03-07T23:45:17Z
Comment #2 by dlang-bot — 2022-03-08T00:05:06Z
@MoonlightSentinel created dlang/dmd pull request #13777 "Fix 22858 - Don't skip alignment of zero-sized fields" fixing this issue: - Fix 22858 - Don't skip alignment of zero-sized fields The exception for `noreturn` should've checked for `T.alignof == 0` instead of `T.sizeof == 0` which also applies to zero-sized arrays. https://github.com/dlang/dmd/pull/13777
Comment #3 by dlang-bot — 2022-03-08T01:53:13Z
dlang/dmd pull request #13777 "Fix 22858 - Don't skip alignment of zero-sized fields" was merged into stable: - e2a9d45a2e27074893c8e8c5f63cf56f95b9764a by MoonlightSentinel: Fix 22858 - Don't skip alignment of zero-sized fields The exception for `noreturn` should've checked for `T.alignof == 0` instead of `T.sizeof == 0` which also applies to zero-sized arrays. https://github.com/dlang/dmd/pull/13777
Comment #4 by dlang-bot — 2022-03-27T02:24:28Z
dlang/dmd pull request #13892 "Merge stable into master" was merged into master: - 94be6147c244f291c1f035499b5e1bf44c874e54 by MoonlightSentinel: Fix 22858 - Don't skip alignment of zero-sized fields The exception for `noreturn` should've checked for `T.alignof == 0` instead of `T.sizeof == 0` which also applies to zero-sized arrays. https://github.com/dlang/dmd/pull/13892