digitalmars.D.bugs - [Issue 22808] New: ImportC: function not decaying to pointer to
- d-bugmail puremagic.com (32/32) Feb 21 2022 https://issues.dlang.org/show_bug.cgi?id=22808
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 puremagic.com Reporter: dave287091 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)` } --
Feb 21 2022