Getting the address of a member function at compile time inside a member function
Paul Backus
snarwin at gmail.com
Sun Jul 13 17:31:41 UTC 2025
On Friday, 11 July 2025 at 10:42:46 UTC, Johan wrote:
> On Monday, 7 July 2025 at 03:28:58 UTC, Steven Schveighoffer
> wrote:
>>
>> ```d
>> void function() fn = &S.bar; // ok!
>> struct S {
>> void bar() {}
>> ```
>
> Very surprising that this works, looks like a clear bug to me
> because it's apparently also allowed for `bar` to access member
> variables. It results in nullptr dereference upon using `this`
> inside `bar`.
Known bug, reported in 2010:
https://issues.dlang.org/show_bug.cgi?id=3720
More information about the Digitalmars-d
mailing list