Bug 13494 – Allow setting delegate member variables to do-nothing stub

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2014-09-18T18:45:18Z
Last change time
2020-03-21T03:56:40Z
Assigned to
No Owner
Creator
hsteoh

Comments

Comment #0 by hsteoh — 2014-09-18T18:45:18Z
There should be a way to set the default value of a delegate member variable to point to a do-nothing stub delegate that simply does nothing: ----- struct S { void delegate(dchar) dg = (dchar) {}; } ----- Currently there is no way to do this, because (1) the compiler doesn't know that the context pointer is actually unused and therefore can be set to null; (2) the compiler appears to be unable to generate code for S.init because it requires resolving the link-time address of the do-nothing delegate's body at compile-time. Both problems are solvable ((1): data flow analysis ought to reveal independence from context-pointer; (2): relocation entries should be generated where the .init value is used, so that the linker can fill in the address of the stub delegate).
Comment #1 by b2.temp — 2020-02-20T10:38:52Z
*** This issue has been marked as a duplicate of issue 20498 ***