[Issue 22808] New: ImportC: function not decaying to pointer to function in return statement.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Feb 22 06:36:43 UTC 2022
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: nobody at puremagic.com
Reporter: dave287091 at gmail.com
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)`
}
--
More information about the Digitalmars-d-bugs
mailing list