Bug 24326 – ImportC: segfault on nameless enum translation with -H

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-01-08T22:54:53Z
Last change time
2024-01-10T13:42:42Z
Keywords
ImportC, pull
Assigned to
No Owner
Creator
Dennis

Comments

Comment #0 by dkorpel — 2024-01-08T22:54:53Z
From the news group: https://forum.dlang.org/post/[email protected] Reduced: ``` enum { A }; ``` Compile with `-H` and you get a segfault. The responsible code is in hdrgen.d: ``` foreach (em; *d.members) { if (!em) continue; buf.writestring("alias "); buf.writestring(em.ident.toString); buf.writestring(" = "); buf.writestring(d.ident.toString); buf.writeByte('.'); buf.writestring(em.ident.toString); buf.writeByte(';'); buf.writenl(); } ``` This assumes enums have a name, but in this case, d.ident is null.
Comment #1 by dlang-bot — 2024-01-10T13:06:21Z
@dkorpel created dlang/dmd pull request #16010 "Fix 24326 - ImportC: segfault on nameless enum translation with -H" fixing this issue: - Fix 24326 - ImportC: segfault on nameless enum translation with -H https://github.com/dlang/dmd/pull/16010
Comment #2 by dlang-bot — 2024-01-10T13:42:42Z
dlang/dmd pull request #16010 "Fix 24326 - ImportC: segfault on nameless enum translation with -H" was merged into stable: - 37947ae6c91a590e0bd49ad227362c2fe39fc8ec by Dennis Korpel: Fix 24326 - ImportC: segfault on nameless enum translation with -H https://github.com/dlang/dmd/pull/16010