---
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