Bug 22175 – assert fail when struct assignment value is desired and struct size is odd

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2021-08-04T06:39:09Z
Last change time
2022-03-27T02:24:26Z
Keywords
backend, ice, industry, pull
Assigned to
No Owner
Creator
FeepingCreature

Comments

Comment #0 by default_357-line — 2021-08-04T06:39:09Z
Consider this code: struct Struct { short a, b, c, d; bool e; } Struct foo() { return Struct(); } void main() { int i; Struct var = i ? Struct() : foo; Struct test() { return var; } } DMD crashes in the backend since 2.097.0.
Comment #1 by dlang-bugzilla — 2021-08-04T06:59:04Z
Comment #2 by default_357-line — 2021-10-25T12:33:52Z
Just ran into it again. :)
Comment #3 by dlang-bot — 2021-11-02T10:27:20Z
@FeepingCreature created dlang/dmd pull request #13255 ""Fix" bug 22175: cdstreq should always use ES:DI for 16-size structs (DO NOT MERGE)" mentioning this issue: - "Fix" bug 22175: cdstreq should use ES:DI for 16-size structs whether or not we're on a platform with segmented access. https://github.com/dlang/dmd/pull/13255
Comment #4 by dlang-bot — 2022-03-09T09:27:59Z
@WalterBright created dlang/dmd pull request #13788 "fix Issue 22175 - assert fail when struct assignment value is desired…" fixing this issue: - fix Issue 22175 - assert fail when struct assignment value is desired and struct size is odd https://github.com/dlang/dmd/pull/13788
Comment #5 by bugzilla — 2022-03-09T09:33:59Z
For anyone needing a workaround, just add fields so the size is 8 bytes.
Comment #6 by bugzilla — 2022-03-09T09:49:01Z
Or just set the alignment of the struct to 16.
Comment #7 by dlang-bot — 2022-03-22T10:54:53Z
dlang/dmd pull request #13788 "fix Issue 22175 - assert fail when struct assignment value is desired…" was merged into stable: - 5549ca01ed82e89fffb5ba607c3cda004ef308b9 by Walter Bright: fix Issue 22175 - assert fail when struct assignment value is desired and struct size is odd https://github.com/dlang/dmd/pull/13788
Comment #8 by dlang-bot — 2022-03-27T02:24:26Z
dlang/dmd pull request #13892 "Merge stable into master" was merged into master: - 7ec00117e9331043d3729ff52486e2c236fcf9e8 by Walter Bright: fix Issue 22175 - assert fail when struct assignment value is desired and struct size is odd (#13788) https://github.com/dlang/dmd/pull/13892