[PATCH] ipa-modref-tree.c: fix selftest leaks

David Malcolm dmalcolm@redhat.com
Thu Oct 22 10:25:13 GMT 2020


"make selftest-valgrind" was reporting:

40 bytes in 1 blocks are definitely lost in loss record 25 of 735
   at 0x483AE7D: operator new(unsigned long) (vg_replace_malloc.c:344)
   by 0xFA0CEA: selftest::test_insert_search_collapse() (ipa-modref-tree.c:40)
   by 0xFA2F9B: selftest::ipa_modref_tree_c_tests() (ipa-modref-tree.c:164)
   by 0x256E3AB: selftest::run_tests() (selftest-run-tests.c:93)
   by 0x1366A8B: toplev::run_self_tests() (toplev.c:2385)
   by 0x1366C47: toplev::main(int, char**) (toplev.c:2467)
   by 0x263203F: main (main.c:39)

40 bytes in 1 blocks are definitely lost in loss record 26 of 735
   at 0x483AE7D: operator new(unsigned long) (vg_replace_malloc.c:344)
   by 0xFA264A: selftest::test_merge() (ipa-modref-tree.c:123)
   by 0xFA2FA0: selftest::ipa_modref_tree_c_tests() (ipa-modref-tree.c:165)
   by 0x256E3AB: selftest::run_tests() (selftest-run-tests.c:93)
   by 0x1366A8B: toplev::run_self_tests() (toplev.c:2385)
   by 0x1366C47: toplev::main(int, char**) (toplev.c:2467)
   by 0x263203F: main (main.c:39)

40 bytes in 1 blocks are definitely lost in loss record 27 of 735
   at 0x483AE7D: operator new(unsigned long) (vg_replace_malloc.c:344)
   by 0xFA279E: selftest::test_merge() (ipa-modref-tree.c:130)
   by 0xFA2FA0: selftest::ipa_modref_tree_c_tests() (ipa-modref-tree.c:165)
   by 0x256E3AB: selftest::run_tests() (selftest-run-tests.c:93)
   by 0x1366A8B: toplev::run_self_tests() (toplev.c:2385)
   by 0x1366C47: toplev::main(int, char**) (toplev.c:2467)
   by 0x263203F: main (main.c:39)

With this patch, the output is clean.

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.

OK for master?

gcc/ChangeLog:
	* ipa-modref-tree.c (selftest::test_insert_search_collapse): Fix
	leak.
	(selftest::test_merge): Fix leaks.
---
 gcc/ipa-modref-tree.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gcc/ipa-modref-tree.c b/gcc/ipa-modref-tree.c
index 1a595090b6c..94c68cc4969 100644
--- a/gcc/ipa-modref-tree.c
+++ b/gcc/ipa-modref-tree.c
@@ -111,6 +111,8 @@ test_insert_search_collapse ()
   ASSERT_TRUE (t->every_base);
   ASSERT_EQ (t->bases, NULL);
   ASSERT_EQ (t->search (1), NULL);
+
+  delete t;
 }
 
 static void
@@ -155,6 +157,9 @@ test_merge ()
   base_node = t1->search (3);
   ASSERT_EQ (base_node->refs, NULL);
   ASSERT_TRUE (base_node->every_ref);
+
+  delete t1;
+  delete t2;
 }
 
 
-- 
2.26.2



More information about the Gcc-patches mailing list