Skip to content

Commit

Permalink
add future
Browse files Browse the repository at this point in the history
Signed-off-by: Jade Abraham <[email protected]>
  • Loading branch information
jabraham17 committed Sep 11, 2024
1 parent 431c2da commit 5d4f573
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/functions/iterators/bugs/iter-memory-leak-unpack.bad
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{id = 2}
deinit C id=2
{id = 4}
deinit C id=4
(id = 2)
deinit R id=2
deinit R id=2
deinit R id=1
(id = 4)
deinit R id=4
deinit R id=4
deinit R id=3

=================================================== Memory Leaks ====================================================
Allocated Memory (Bytes) Number Size Total Description Address
=====================================================================================================================
iter-memory-leak-unpack.chpl:26 1 16 16 C prediffed
iter-memory-leak-unpack.chpl:26 1 16 16 C prediffed
=====================================================================================================================

31 changes: 31 additions & 0 deletions test/functions/iterators/bugs/iter-memory-leak-unpack.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class C {
var id: int;
proc deinit() {
writeln("deinit C id=", id);
}
}

record R {
var id: int;
proc deinit() {
writeln("deinit R id=", id);
}
}

iter foo() {
yield (new C(1), new C(2));
yield (new C(3), new C(4));
}

iter bar() {
yield (new R(1), new R(2));
yield (new R(3), new R(4));
}


for (_, x) in foo() {
writeln(x);
}
for (_, x) in bar() {
writeln(x);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--memLeaks
2 changes: 2 additions & 0 deletions test/functions/iterators/bugs/iter-memory-leak-unpack.future
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bug: ignoring a value in a tuple unpack doesn't invoke the destructor
#25926
16 changes: 16 additions & 0 deletions test/functions/iterators/bugs/iter-memory-leak-unpack.good
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{id = 2}
deinit C id=2
deinit C id=1
{id = 4}
deinit C id=4
deinit C id=3
(id = 2)
deinit R id=2
deinit R id=1
deinit R id=2
deinit R id=1
(id = 4)
deinit R id=4
deinit R id=3
deinit R id=4
deinit R id=3
4 changes: 4 additions & 0 deletions test/functions/iterators/bugs/iter-memory-leak-unpack.prediff
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

sed -E "s/0x[0-9a-f]*/prediffed/" <$2 >$2.predifftmp
mv $2.predifftmp $2

0 comments on commit 5d4f573

Please sign in to comment.