[Issue 21537] Function pointer* pointer' attributes not covariant when referencing (delegates' are)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Nov 27 01:54:27 UTC 2021


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

--- Comment #5 from Bolpat <qs.il.paperinik at gmail.com> ---
(In reply to moonlightsentinel from comment #4)
> (In reply to Bolpat from comment #3)
> > How is a pointer to a function pointer morally different from a pointer to a
> > delegate or a pointer to a class object reference?
> 
> It isn't.
>  
> > If types T and S have a subtyping relationship like T ⊆ S, then const(T)* ⊆
> > const(S)*; at least, this is the case when T and S are class types or when T
> > and S are delegate types, but fails when T and S are function pointer types.
> 
> No, such implicit conversion for pointer are already rejected:
> 
> [code]

Of course, if you don't use const, the conversion is not safe. But I did. I
checked it again if I missed it at some point by accident, but at a quick
glance I couldn't find a spot. (Even if there is one, the overall use of const
makes clear what I'm talking about.) Your example demonstrates conversation to
a pointer a mutable supertype object, but the bug report is about pointers to a
const supertype object.
Neither of us is wrong, but we're talking about slightly, but meaningfully
different things. The code you posted is rejected and for good reasons, but it
does not invalidate the bug report.

--


More information about the Digitalmars-d-bugs mailing list