Bug 22242 – ICE when an overload is aliased back into a mixin

Status
RESOLVED
Resolution
WORKSFORME
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-08-26T15:18:04Z
Last change time
2023-02-28T15:25:17Z
Keywords
ice, rejects-valid
Assigned to
No Owner
Creator
Max Samukha

Comments

Comment #0 by maxsamukha — 2021-08-26T15:18:04Z
Compiling this causes a segfault: mixin template Foo() { alias foo = typeof(this).foo; // (1) void foo(int a) { ubyte b; foo(b); } } struct S { void foo(ubyte a) { } mixin Foo f; alias foo = f.foo; } void main() { } It is order-dependent: if (1) is placed after foo's definition, the code compiles.
Comment #1 by snarwin+bugzilla — 2021-08-26T17:26:10Z
The segfault is caused by infinite recursion in dmd.func.overloadApply, which overflows the stack. Specifically, it is caused by this recursive call: https://github.com/dlang/dmd/blob/717a966b8c85751390ebc5fbc77302c1d876a0a5/src/dmd/func.d#L2758 ...which does not account for the possibility that a FuncAliasDeclaration's funcalias member may point to itself.
Comment #2 by razvan.nitu1305 — 2023-02-28T15:25:17Z
This seems to have been fixed in the latest version of the compiler. Closing as WORKSFORME. Please reopen if you can reproduce.