Bug 23045 – importC: casted function type is missing extern(C)
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-04-22T00:55:10Z
Last change time
2022-05-05T21:04:18Z
Keywords
ImportC, pull, wrong-code
Assigned to
No Owner
Creator
duser
Comments
Comment #0 by duser — 2022-04-22T00:55:10Z
int printf(char *, ...);
void other(int a, int b)
{
printf("a=%d b=%d\n", a, b);
}
int main()
{
// called like extern(D)
((void (*)(int, int))other)(1, 2);
// Error: incompatible types for `(cast(void function(int, int))& other) is (other)`: `void function(int, int)` and `extern (C) void(int a, int b)`
if (((void (*)(int, int))other) == other)
{}
}
on 64-bit linux, the call prints "a=2 b=1" since arguments to extern(D) functions are passed in reverse order
Comment #1 by dlang-bot — 2022-04-23T23:34:01Z
@WalterBright created dlang/dmd pull request #14024 "fix Issue 23045 - importC: casted function type is missing extern(C)" fixing this issue:
- fix Issue 23045 - importC: casted function type is missing extern(C)
https://github.com/dlang/dmd/pull/14024
Comment #2 by dlang-bot — 2022-04-25T09:47:56Z
dlang/dmd pull request #14024 "fix Issue 23045 - importC: casted function type is missing extern(C)" was merged into master:
- b989082dcd87095cc90d489172e806daf938a553 by Walter Bright:
fix Issue 23045 - importC: casted function type is missing extern(C)
https://github.com/dlang/dmd/pull/14024
Comment #3 by dlang-bot — 2022-05-01T16:36:14Z
dlang/dmd pull request #14054 "fix Issue 23045 - importC: casted function type is missing extern(C)" was merged into stable:
- 9315e53dfc317d309c2398b6bd34e5b8255c228b by Walter Bright:
fix Issue 23045 - importC: casted function type is missing extern(C) (#14024)
https://github.com/dlang/dmd/pull/14054
Comment #4 by dlang-bot — 2022-05-05T21:04:18Z
dlang/dmd pull request #14064 "merge stable" was merged into master:
- 84af0a8586450025d2b22ab623224d074d2ec4b8 by Walter Bright:
fix Issue 23045 - importC: casted function type is missing extern(C) (#14024)
https://github.com/dlang/dmd/pull/14064