D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4162 - pass by alias offset problems
Summary: pass by alias offset problems
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Linux
: P2 major
Assignee: No Owner
URL:
Keywords: ice
Depends on:
Blocks:
 
Reported: 2010-05-06 15:00 UTC by Kyle Foley
Modified: 2013-11-18 08:41 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 Kyle Foley 2010-05-06 15:00:35 UTC
DMD 2.045
---
import std.stdio;

struct B(alias _)
{
	void print() { writeln(&_); }
}

struct C(alias _)
{
	int i;
	void print() { writeln(&_); }
}

int main(string[] args)
{
	int a;

	auto b = B!(a)();
	writeln(&a);
	b.print();

	auto c = C!(a)();
	writeln(&a);
	c.print();
	
	return 0;
}

---
$ rdmd passByAlias.d
B75B5E54
B75B5E54
B75B5E54
804E358
end
zsh: segmentation fault  rdmd passByAlias.d
---

It seems that C having a field messes with what DMD thinks the _ alias refers to.
Comment 1 Kenji Hara 2013-11-18 05:53:25 UTC
Fixed in 2.050.
Comment 2 github-bugzilla 2013-11-18 08:41:58 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/c85f088cd88cfc62a40b7406b7203c738a65d39f
fix Issue 4162 - pass by alias offset problems