Commit 22620c14 by Jonathan Wakely Committed by Jonathan Wakely

Remove memory leaks in libstdc++ testsuite

	* testsuite/18_support/new_delete_placement.cc: Don't allocate (and
	leak) memory for arguments to placement delete.
	* testsuite/20_util/addressof/1.cc: Don't leak memory.
	* testsuite/22_locale/locale/global_locale_objects/3.cc: Likewise.
	* testsuite/23_containers/unordered_multimap/insert/55028-debug.cc:
	Likewise.

From-SVN: r238607
parent cfd97da1
2016-07-21 Jonathan Wakely <jwakely@redhat.com>
* testsuite/18_support/new_delete_placement.cc: Don't allocate (and
leak) memory for arguments to placement delete.
* testsuite/20_util/addressof/1.cc: Don't leak memory.
* testsuite/22_locale/locale/global_locale_objects/3.cc: Likewise.
* testsuite/23_containers/unordered_multimap/insert/55028-debug.cc:
Likewise.
2016-07-20 Jonathan Wakely <jwakely@redhat.com> 2016-07-20 Jonathan Wakely <jwakely@redhat.com>
* doc/xml/manual/intro.xml: Document DR 2684 status. * doc/xml/manual/intro.xml: Document DR 2684 status.
......
...@@ -25,11 +25,11 @@ ...@@ -25,11 +25,11 @@
// libstdc++/7286 // libstdc++/7286
void test01() void test01()
{ {
void* pc = new char; char c = 'c';
void* pa = new char[10]; void* p = &c;
void* tmp = 0; void* tmp = 0;
operator delete(pc, tmp); operator delete(p, tmp);
operator delete[](pa, tmp); operator delete[](p, tmp);
} }
int main() int main()
......
...@@ -41,6 +41,9 @@ void test01() ...@@ -41,6 +41,9 @@ void test01()
VERIFY( std::addressof(o2) == ao2 ); VERIFY( std::addressof(o2) == ao2 );
VERIFY( std::addressof(f1) == &f1 ); VERIFY( std::addressof(f1) == &f1 );
delete ao1;
delete ao2;
} }
int main() int main()
......
...@@ -73,13 +73,15 @@ void test03() ...@@ -73,13 +73,15 @@ void test03()
VERIFY( loc04 == global_orig ); VERIFY( loc04 == global_orig );
} }
// 2: Not destroyed when out of scope, deliberately leaked. // 2: Not destroyed when out of scope, deliberately "leaked".
const facet_type* ptr = 0;
{ {
{ {
{ {
VERIFY( counter == 0 ); VERIFY( counter == 0 );
{ {
locale loc01(locale::classic(), new facet_type(1)); ptr = new facet_type(1);
locale loc01(locale::classic(), ptr);
VERIFY( counter == 1 ); VERIFY( counter == 1 );
global_orig = locale::global(loc01); global_orig = locale::global(loc01);
name = loc01.name(); name = loc01.name();
...@@ -101,6 +103,9 @@ void test03() ...@@ -101,6 +103,9 @@ void test03()
} }
VERIFY( counter == 1 ); VERIFY( counter == 1 );
// Clean up.
delete ptr;
// Restore global settings. // Restore global settings.
locale::global(global_orig); locale::global(global_orig);
} }
......
...@@ -30,7 +30,7 @@ void test() ...@@ -30,7 +30,7 @@ void test()
// using MyMap = std::multimap<std::string, MyType *>; // works // using MyMap = std::multimap<std::string, MyType *>; // works
using MyMap = std::unordered_multimap<std::string, MyType*>; // fails to link using MyMap = std::unordered_multimap<std::string, MyType*>; // fails to link
MyMap m; MyMap m;
m.insert(std::make_pair(std::string("blah"), new MyType)); m.insert(std::make_pair(std::string("blah"), (MyType*)nullptr));
} }
int main() int main()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment