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
This commit is contained in:
Jonathan Wakely 2016-07-21 20:38:32 +01:00 committed by Jonathan Wakely
parent cfd97da10d
commit 22620c1452
5 changed files with 24 additions and 7 deletions

View File

@ -1,3 +1,12 @@
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>
* doc/xml/manual/intro.xml: Document DR 2684 status.

View File

@ -25,11 +25,11 @@
// libstdc++/7286
void test01()
{
void* pc = new char;
void* pa = new char[10];
char c = 'c';
void* p = &c;
void* tmp = 0;
operator delete(pc, tmp);
operator delete[](pa, tmp);
operator delete(p, tmp);
operator delete[](p, tmp);
}
int main()

View File

@ -41,6 +41,9 @@ void test01()
VERIFY( std::addressof(o2) == ao2 );
VERIFY( std::addressof(f1) == &f1 );
delete ao1;
delete ao2;
}
int main()

View File

@ -73,13 +73,15 @@ void test03()
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 );
{
locale loc01(locale::classic(), new facet_type(1));
ptr = new facet_type(1);
locale loc01(locale::classic(), ptr);
VERIFY( counter == 1 );
global_orig = locale::global(loc01);
name = loc01.name();
@ -101,6 +103,9 @@ void test03()
}
VERIFY( counter == 1 );
// Clean up.
delete ptr;
// Restore global settings.
locale::global(global_orig);
}

View File

@ -30,7 +30,7 @@ void test()
// using MyMap = std::multimap<std::string, MyType *>; // works
using MyMap = std::unordered_multimap<std::string, MyType*>; // fails to link
MyMap m;
m.insert(std::make_pair(std::string("blah"), new MyType));
m.insert(std::make_pair(std::string("blah"), (MyType*)nullptr));
}
int main()