Bug 20501 – Function literals inside enum of function pointers wrongly treated as delegates

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-01-12T15:26:00Z
Last change time
2024-12-13T19:06:49Z
Assigned to
No Owner
Creator
kinke
Moved to GitHub: dmd#19658 →

Comments

Comment #0 by kinke — 2020-01-12T15:26:00Z
The following program compiles fine but is killed at runtime, as it tries to jump to an invalid instruction address: ``` enum E : void function() { First = () {} // `= function() {}` works } void main() { E.First(); // invalid jump } ``` run.dlang.io Linux x64 asm: _Dmain: push RBP mov RBP,RSP mov RCX,pure nothrow @nogc @safe void onlineapp.E.__lambda2()@GOTPCREL[RIP] xor EAX,EAX // btw, why 32-bit only? call RAX xor EAX,EAX pop RBP ret
Comment #1 by robert.schadek — 2024-12-13T19:06:49Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19658 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB