[Issue 22884] New: ImportC: error when casting between function pointers for statically initialized variables
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Mar 17 07:32:31 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=22884
Issue ID: 22884
Summary: ImportC: error when casting between function pointers
for statically initialized variables
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: ImportC, rejects-valid
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dave287091 at gmail.com
The following C code fails to compile. This kind of pointer cast can be seen in
sqlite and also in some C library APIs like python.
int printf(const char*, ...);
typedef void (*funcptr)(void);
funcptr a = printf; // ok
funcptr b = (funcptr)printf; // Error: non-constant expression `printf`
funcptr foo(void){
funcptr f = (funcptr)printf; // ok
return f;
}
--
More information about the Digitalmars-d-bugs
mailing list