diff --git a/test/functions/iterators/bugs/iter-memory-leak-unpack.bad b/test/functions/iterators/bugs/iter-memory-leak-unpack.bad new file mode 100644 index 000000000000..5c9c57dfdb42 --- /dev/null +++ b/test/functions/iterators/bugs/iter-memory-leak-unpack.bad @@ -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 +===================================================================================================================== + diff --git a/test/functions/iterators/bugs/iter-memory-leak-unpack.chpl b/test/functions/iterators/bugs/iter-memory-leak-unpack.chpl new file mode 100644 index 000000000000..466fb76438ed --- /dev/null +++ b/test/functions/iterators/bugs/iter-memory-leak-unpack.chpl @@ -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); +} diff --git a/test/functions/iterators/bugs/iter-memory-leak-unpack.execopts b/test/functions/iterators/bugs/iter-memory-leak-unpack.execopts new file mode 100644 index 000000000000..0e124c953c80 --- /dev/null +++ b/test/functions/iterators/bugs/iter-memory-leak-unpack.execopts @@ -0,0 +1 @@ +--memLeaks diff --git a/test/functions/iterators/bugs/iter-memory-leak-unpack.future b/test/functions/iterators/bugs/iter-memory-leak-unpack.future new file mode 100644 index 000000000000..11daf9339713 --- /dev/null +++ b/test/functions/iterators/bugs/iter-memory-leak-unpack.future @@ -0,0 +1,2 @@ +bug: ignoring a value in a tuple unpack doesn't invoke the destructor +#25926 diff --git a/test/functions/iterators/bugs/iter-memory-leak-unpack.good b/test/functions/iterators/bugs/iter-memory-leak-unpack.good new file mode 100644 index 000000000000..2f50d521a2ab --- /dev/null +++ b/test/functions/iterators/bugs/iter-memory-leak-unpack.good @@ -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 diff --git a/test/functions/iterators/bugs/iter-memory-leak-unpack.prediff b/test/functions/iterators/bugs/iter-memory-leak-unpack.prediff new file mode 100755 index 000000000000..3762f3755985 --- /dev/null +++ b/test/functions/iterators/bugs/iter-memory-leak-unpack.prediff @@ -0,0 +1,4 @@ +#!/bin/bash + +sed -E "s/0x[0-9a-f]*/prediffed/" <$2 >$2.predifftmp +mv $2.predifftmp $2