Bug 22808 – ImportC: function not decaying to pointer to function in return statement.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-02-22T06:36:43Z
Last change time
2022-03-02T10:10:56Z
Keywords
ImportC, pull, rejects-valid
Assigned to
No Owner
Creator
dave287091

Comments

Comment #0 by dave287091 — 2022-02-22T06:36:43Z
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)` }
Comment #1 by dlang-bot — 2022-03-02T07:55:30Z
@WalterBright created dlang/dmd pull request #13743 "fix Issue 22808 - ImportC: function not decaying to pointer to functi…" fixing this issue: - fix Issue 22808 - ImportC: function not decaying to pointer to function in return statement https://github.com/dlang/dmd/pull/13743
Comment #2 by dlang-bot — 2022-03-02T10:10:56Z
dlang/dmd pull request #13743 "fix Issue 22808 - ImportC: function not decaying to pointer to functi…" was merged into master: - 783e3cb6d5ba2b2f3b1a4681ce822378fd58762c by Walter Bright: fix Issue 22808 - ImportC: function not decaying to pointer to function in return statement https://github.com/dlang/dmd/pull/13743