D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 23045 - importC: casted function type is missing extern(C)
Summary: importC: casted function type is missing extern(C)
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: ImportC, pull, wrong-code
Depends on:
Blocks:
 
Reported: 2022-04-22 00:55 UTC by duser
Modified: 2022-05-05 21:04 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description duser 2022-04-22 00:55:10 UTC
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 Dlang Bot 2022-04-23 23:34:01 UTC
@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 Dlang Bot 2022-04-25 09:47:56 UTC
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 Dlang Bot 2022-05-01 16:36:14 UTC
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 Dlang Bot 2022-05-05 21:04:18 UTC
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