[Issue 22989] New: Missing error wrt. assigning cast function pointer to incompatible funcptr
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Apr 5 13:21:09 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=22989
Issue ID: 22989
Summary: Missing error wrt. assigning cast function pointer to
incompatible funcptr
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: kinke at gmx.net
With DMD v2.099.0:
```
extern(C) bool foo1(int i) { return i != 0; }
extern(C) char foo2(int i) { return i != 0; }
alias F1 = extern(C) bool function(int);
alias F2 = extern(C) char function(int);
void main() {
{ // normal
F1 f1 = &foo1;
F2 f2 = &foo2;
}
{ // explicit cast
F2 f1 = cast(F2) &foo1;
F1 f2 = cast(F1) &foo2;
}
{ // cast, but mismatch
F1 f1 = cast(F2) &foo1; // bug: no error - cast seems omitted
F2 f2 = cast(F1) &foo2; // ditto
}
}
```
--
More information about the Digitalmars-d-bugs
mailing list