Issue 13891 - __gshared/static anonymous union members do not overlap
Summary: __gshared/static anonymous union members do not overlap
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P3 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-25 08:48 UTC by Vlad Levenfeld
Modified: 2024-09-21 19:53 UTC (History)
3 users (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-12-25 08:48:15 UTC
struct Foo
{
	union {
		int a;
		int b;
	}
}
struct Bar
{
	__gshared union { // also fails if __gshared -> static
		int a;
		int b;
	}
}
void main (string[] args)
{
	Foo x; Bar y;

	assert (cast(uint)(&x.a) == cast(uint)(&x.b)); // PASS
	assert (cast(uint)(&y.a) == cast(uint)(&y.b)); // FAIL
}
Comment 1 Nick Treleaven 2024-09-21 19:53:42 UTC
Still happens with 2.109. Also:

pragma(msg, Foo.b.offsetof); // 0
pragma(msg, Bar.b.offsetof); // Error: no property `offsetof` for `b` of type `int`