Bug 23549 – assert(0) as default parameter causes segfault

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-12-10T18:26:01Z
Last change time
2022-12-15T22:50:08Z
Keywords
ice, ice-on-valid-code, pull
Assigned to
No Owner
Creator
elpenguino+D

Comments

Comment #0 by elpenguino+D — 2022-12-10T18:26:01Z
This code ``` void main() { foo(); //commenting this out lets this compile successfully foo(3); } int foo(int g = assert(0)) { return g; } ``` causes dmd to segfault since version 2.098. Up until 2.098, this produced an incorrect error instead: `Error: e2ir: cannot cast 'assert(0)' of type 'noreturn' to type 'int'`.
Comment #1 by dlang-bot — 2022-12-15T06:25:29Z
@maxhaton created dlang/dmd pull request #14698 "Fix Issue 23549, 22587 - Lower certain noreturn expressions to a comm…" fixing this issue: - Fix Issue 23549, 22587 - Lower certain noreturn expressions to a comma expression rather than a cast. This avoids a backend segfault. GDC already does this lowering so it may have to be made optional via a frontend parameter. https://github.com/dlang/dmd/pull/14698
Comment #2 by dlang-bot — 2022-12-15T13:46:03Z
dlang/dmd pull request #14698 "Fix Issue 23549, 22587 - Lower certain noreturn expressions to a comm…" was merged into stable: - 5dd1f2942482d730418af8d7d3c5f754122116b8 by mhh: Fix Issue 23549, 22587 - Lower certain noreturn expressions to a comma expression rather than a cast. This avoids a backend segfault. GDC already does this lowering so it may have to be made optional via a frontend parameter. https://github.com/dlang/dmd/pull/14698
Comment #3 by dlang-bot — 2022-12-15T22:50:08Z
dlang/dmd pull request #14701 "merge stable" was merged into master: - d836c8bcec16205644e3aacf15f1a1cf7d655dd5 by mhh: Fix Issue 23549, 22587 - Lower certain noreturn expressions to a comma expression rather than a cast. This avoids a backend segfault. GDC already does this lowering so it may have to be made optional via a frontend parameter. https://github.com/dlang/dmd/pull/14701