Bug 24257 – ImportC: ICE on accessing last _Bool bitfield

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2023-11-23T22:53:46Z
Last change time
2023-11-26T12:12:06Z
Keywords
ice, ImportC, pull
Assigned to
No Owner
Creator
Dennis

Comments

Comment #0 by dkorpel — 2023-11-23T22:53:46Z
``` typedef struct { unsigned : 15; _Bool done : 1; } S; _Bool advance() { S n; if (n->done) {} } ``` Results in: ``` core.exception.AssertError@src/dmd/backend/cgelem.d(3202): Assertion failure ---------------- ??:? _d_assertp [0x556b0f3b40c0] src/dmd/backend/cgelem.d:3202 nothrow @trusted dmd.backend.el.elem* dmd.backend.cgelem.elbit(dmd.backend.el.elem*, uint) [0x556b0f2dc5dc] src/dmd/backend/cgelem.d:6147 nothrow @trusted dmd.backend.el.elem* dmd.backend.cgelem.optelem(dmd.backend.el.elem*, uint) [0x556b0f2e2f93] src/dmd/backend/cgelem.d:6178 nothrow @trusted dmd.backend.el.elem* dmd.backend.cgelem.doptelem(dmd.backend.el.elem*, uint) [0x556b0f2e2ff1] ```
Comment #1 by bugzilla — 2023-11-24T05:43:12Z
Since n is not a pointer, this should be a semantic error.
Comment #2 by dkorpel — 2023-11-24T08:38:19Z
Looks like dustmite found another bug by reducing away the star from the type. Filed as issue 24259. Fixed test case: ``` typedef struct { unsigned : 15; _Bool done : 1; } S; _Bool advance() { S *n; if (n->done) {} } ```
Comment #3 by bugzilla — 2023-11-24T22:43:54Z
This is not an ImportC specific bug, the same code in D exhibits the same failure: struct S { uint : 15; bool done : 1; } void advance() { S n; if (n.done) {} }
Comment #4 by dlang-bot — 2023-11-25T04:21:36Z
@WalterBright created dlang/dmd pull request #15861 "fix Issue 24257 - ImportC: ICE on accessing last _Bool bitfield" fixing this issue: - fix Issue 24257 - ImportC: ICE on accessing last _Bool bitfield https://github.com/dlang/dmd/pull/15861
Comment #5 by dlang-bot — 2023-11-25T21:45:37Z
dlang/dmd pull request #15861 "fix Issue 24257 - ImportC: ICE on accessing last _Bool bitfield" was merged into stable: - 80dcf2c00e8e086a8c78a336e714a00f73c63ffd by Walter Bright: fix Issue 24257 - ImportC: ICE on accessing last _Bool bitfield https://github.com/dlang/dmd/pull/15861
Comment #6 by dlang-bot — 2023-11-26T12:12:06Z
dlang/dmd pull request #15865 "Merge stable into master" was merged into master: - e1197fc765d0b94470a96f8655e9e2d7d8267a66 by Walter Bright: fix Issue 24257 - ImportC: ICE on accessing last _Bool bitfield (#15861) https://github.com/dlang/dmd/pull/15865