aboutsummaryrefslogtreecommitdiff
path: root/tests/conformance/6-ownership/drop_elements_pop_ok.zc
blob: 9c97e442687e398f0267098590afe04f2789bd06 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
// expect: 5 drop5 after 
// destructors 6.15.5: an array without a drop can hand out a droppable element; pop gives it to the new owner, whose block end drops it
include rt;
struct node { int v; void drop() { rt.put_s("drop"); rt.put_n(this.v); rt.put_s(" "); } }
fn main() {
	node*[?] a = rt.new(node*[?]);
	node* x = rt.new(node); x.v = 5; a.push(x);
	{ node* y = a.pop(); rt.put_n(y.v); rt.put_s(" "); }
	rt.put_s("after ");
	return 0;
}
// zc0: skip