[Issue 21537] Pointer to function pointer cannot be converted to pointer to const function pointer with lower attributes
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Nov 27 14:31:55 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=21537
--- Comment #6 from moonlightsentinel at disroot.org ---
Right, I've fixed the example. Conversions including const class references are
accepted but both conversion including FP and delegates are rejected on
nightly:
For reference:
class A {}
class B : A {}
alias SysFP = void function();
alias SafeFP = void function() @safe;
alias SysDG = void delegate();
alias SafeDG = void delegate() @safe;
void main()
{
{
A a;
B b;
a = b; // Fine
}{
const(A)* ap;
const(B)* bp;
ap = bp; // Accepted
}{
SafeFP safeFp;
SysFP sysFp;
sysFp = safeFp; // Fine
}{
const(SafeFP)* safeFpPtr;
const(SysFP)* sysFpPtr;
sysFpPtr = safeFpPtr; // Error: cannot implicitly convert expression
`safeFpPtr` of type `const(void function() @safe)*` to `const(void
function())*`
}{
SafeDG safeDg;
SysDG sysDg;
sysDg = safeDg; // Fine
}{
const(SafeDG)* safeDgPtr;
const(SysDG)* sysDgPtr;
sysDgPtr = safeDgPtr; // Error: cannot implicitly convert expression
`safeDgPtr` of type `const(void delegate() @safe)*` to `const(void
delegate())*`
}
}
--
More information about the Digitalmars-d-bugs
mailing list