[Issue 20501] New: Function literals inside enum of function pointers wrongly treated as delegates
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jan 12 15:26:00 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20501
Issue ID: 20501
Summary: Function literals inside enum of function pointers
wrongly treated as delegates
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: kinke at gmx.net
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
--
More information about the Digitalmars-d-bugs
mailing list