Bug 20230 – dmd-specific runtime segfault due to inconsistent conversion of function closure to delegate at compile time

Status
NEW
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2019-09-19T13:00:21Z
Last change time
2024-12-13T19:05:40Z
Assigned to
No Owner
Creator
Muffindrake
Moved to GitHub: dmd#19623 →

Comments

Comment #0 by muffindrake — 2019-09-19T13:00:21Z
--- struct A { int delegate(int) f; int delegate(int) g; } A s; A r = { f: delegate (int v) { return 41 + v; }, g: (int v) { return 665 + v; } }; A u = { f: delegate (int v) { return 41 + v; }, g: delegate (int v) { return 665 + v; } }; void main() { import std.stdio; s.f = delegate (int v) { return 41 + v; }; s.g = (int v) { return 665 + v; }; s.f(1).writeln; s.g(1).writeln; u.f(1).writeln; u.g(1).writeln; r.f(1).writeln; r.g(1).writeln; /* segfault on dmd */ } --- I stumbled upon this issue through pure accident where I meant to be using function instead of delegate in a structure field, and I only noticed the problem when I compiled with dmd once in a blue moon, rather than ldc2 which doesn't exhibit the segfault.
Comment #1 by robert.schadek — 2024-12-13T19:05:40Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19623 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB