aboutsummaryrefslogtreecommitdiff
path: root/tests/conformance/4-statements/uninit_struct_fields_ok.zc
blob: a12fa713241bb02ffedd0ba878d6cc13deb60e12 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
// expect: 3/7/
// spec 4.1.5: a written field may be read before the rest; writing every field sets the struct
include rt;
struct point { int x; int y; }
fn sum(point* q) { return q.x + q.y; }
fn main() {
	point p;
	p.x = 3;
	rt.put_n(p.x); rt.put_c(10);
	p.y = 4;
	rt.put_n(sum(&p)); rt.put_c(10);
	return 0;
}