Skip to content

Ugly code for anonymous union inside struct #297

@Temtaime

Description

@Temtaime
struct B
{
	union
	{
		int a;
		char c;
	};
};

Produces:

extern (C)
{
	struct B
	{
		static union _Anonymous_0
		{
			int a;
			char c;
		}

		_Anonymous_0 _anonymous_1;
		ref auto a() @property @nogc pure nothrow
		{
			return _anonymous_1.a;
		}

		void a(_T_)(auto ref _T_ val) @property @nogc pure nothrow
		{
			_anonymous_1.a = val;
		}

		ref auto c() @property @nogc pure nothrow
		{
			return _anonymous_1.c;
		}

		void c(_T_)(auto ref _T_ val) @property @nogc pure nothrow
		{
			_anonymous_1.c = val;
		}
	}
}

I do not see any reasons for those properties. Anonymous unions are allowed in D.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions