diff options
Diffstat (limited to 'tests/conformance/6-ownership/borrow_outlives_block.zc')
| -rw-r--r-- | tests/conformance/6-ownership/borrow_outlives_block.zc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/conformance/6-ownership/borrow_outlives_block.zc b/tests/conformance/6-ownership/borrow_outlives_block.zc new file mode 100644 index 0000000..4d9b44a --- /dev/null +++ b/tests/conformance/6-ownership/borrow_outlives_block.zc @@ -0,0 +1,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 |
