https://issues.dlang.org/show_bug.cgi?id=22808
Issue ID: 22808
Summary: ImportC: function not decaying to pointer to function
in return statement.
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: ImportC, rejects-valid
Severity: normal
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
The following C code fails to compile:
typedef int(*cmp)(int, int);
int icmp(int a, int b){
return a < b ? -1 : b < a? 1 : 0;
}
cmp getcmp(void){
cmp c;
c = icmp; // ok
c = &icmp; // ok
if(0)
return c; // ok
if(0)
return &icmp; // ok
return icmp; // Error: cannot implicitly convert expression `icmp` of type
`extern (C) int(int a, int b)` to `extern (C) int function(int, int)`
}
--