[Issue 3720] Taking address of member functions possible without an instance

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 20 16:17:17 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=3720

--- Comment #24 from Bolpat <qs.il.paperinik at gmail.com> ---
@Zombine(In reply to ZombineDev from comment #18)
> […]
> 
> 2. After deprecation period is finished, reintroduce the
> &<AggregateType>.<memberFunction> but with different semantics: retunring a
> delegate with context pointer set to null.

Why? If I want a delegate with a null pointer context and member function
mfunc, today I can do
```d
alias T = the-aggregate-type;
auto dg = &(cast(T*)null).mfunc;
```
As an added benefit, it is absolutely clear what happens.

If that is not defined behavior because of supposed null pointer dereference,
we can just make it a special-case and allow it.

--


More information about the Digitalmars-d-bugs mailing list