April 05, 2022 [Issue 22989] New: Missing error wrt. assigning cast function pointer to incompatible funcptr | ||||
|---|---|---|---|---|
| ||||
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@puremagic.com Reporter: kinke@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 } } ``` -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply