view run/u/union_17_H.d @ 1033:439495a3c7c4

weird crash when nesting unions and structs; code order dependent <h3r3tic@mat.uni.torun.pl> 2006-05-27 news:bug-158-3@http.d.puremagic.com/bugzilla/
author thomask
date Thu, 01 Jun 2006 17:50:13 +0000
parents
children 81222734adf3
line wrap: on
line source

// $HeadURL$
// $Date$
// $Author$

// @author@	<h3r3tic@mat.uni.torun.pl>
// @date@	2006-05-27
// @uri@	news:bug-158-3@http.d.puremagic.com/bugzilla/

module dstress.run.u.union_17_H;

struct Foo {
	int i;
}

struct Bar {
	union {
		struct {
			Foo f;
		}
	}
}

static if(Foo.sizeof != Bar.sizeof){
	static assert(0);
}

int main(){
	Foo a;
	a.i = 2;
	
	Bar b;
	b.f = a;

	a.i = 3;
	
	if(a.i != 3){
		assert(0);
	}

	if(b.f.i != 2){
		assert(0);
	}

	return 0;
}