D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 13238 - getMember trait changes function linkage
Summary: getMember trait changes function linkage
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 minor
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-01 18:10 UTC by Vlad Levenfeld
Modified: 2020-03-21 03:56 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 Vlad Levenfeld 2014-08-01 18:10:37 UTC
struct Foo
{
	extern (C) void function (int*) func;
}
struct Bar
{
	static string code ()
	{
		string code;

		foreach (symbol; __traits (allMembers, typeof(this)))
			static if (is(typeof(__traits (getMember, typeof(this), symbol))))
				{}

		return code;
	}

	extern (C) void function (int*) func;

	mixin(code);
}
struct Baz
{
	static string code ()
	{
		string code;

		foreach (symbol; __traits (allMembers, typeof(this)))
			static if (is(typeof(__traits (getMember, typeof(this), symbol))))
				{}

		return code;
	}

	mixin(code);

	extern (C) void function (int*) func;
}

void main () 
{
	static assert (functionLinkage!(typeof(Foo.func)) == `C`);
	static assert (functionLinkage!(typeof(Bar.func)) == `C`);
	static assert (functionLinkage!(typeof(Baz.func)) == `D`); // BUG why?
}