aboutsummaryrefslogtreecommitdiff
path: root/tests/conformance/6-ownership/borrow_outlives_block.zc
blob: 4d9b44af92db6e20c63771402bbc4ec0eae32a09 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// expect error: second: borrows from head, which was freed at the end of its block (line 17)
// spec 6.6.3
include rt;

struct node {
	int value;
	node* next;
};

fn main() {
	node* second;
	{
		node* head = rt.new(node);
		head.next = rt.new(node);
		head.next.value = 1;
		second = head.next;
	}
	rt.put_n(second.value);
	rt.put_c(10);
}
// zc0: skip