Bug 22662 – ICE caused by forward reference

Status
NEW
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-01-10T03:06:04Z
Last change time
2024-12-13T19:20:22Z
Keywords
ice
Assigned to
No Owner
Creator
Paul Backus
Moved to GitHub: dmd#18077 →

Comments

Comment #0 by snarwin+bugzilla — 2022-01-10T03:06:04Z
As of DMD 2.098.1, the following program fails to compile: --- enum isHashable(T) = __traits(compiles, T.init.tupleof[0][0].sizeof); struct SumType(Types...) { union Storage { Types values; } Storage storage; static if (isHashable!(Types[0])) {} } string[] toLines(Expression val) { return []; } alias Expression = SumType!(Scope, Return); struct Return { Expression* _expr = new Expression; } struct Scope { Expression[] statements; string[] toLines() { return Expression.init.toLines; } } --- When attempting to compile, DMD gives the following output: --- Error: unknown, please file report on issues.dlang.org --- Any further reduction of the example program either causes compilation to succeed, or results in a different error.
Comment #1 by moonlightsentinel — 2022-01-17T14:54:20Z
The code was silently accepted before https://github.com/dlang/dmd/pull/9425
Comment #2 by moonlightsentinel — 2022-01-17T15:19:53Z
The actual error message: --- Error: cannot use non-constant CTFE pointer in an initializer `&SumType(Storage(Scope(null), Return(void)))` --- Suppressed since https://github.com/dlang/dmd/pull/8583
Comment #3 by robert.schadek — 2024-12-13T19:20:22Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18077 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB