mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-19 08:29:18 +08:00
New test case.
From-SVN: r31432
This commit is contained in:
parent
64f1326a88
commit
f2aabbd80d
33
gcc/testsuite/g++.old-deja/g++.ns/new1.C
Normal file
33
gcc/testsuite/g++.old-deja/g++.ns/new1.C
Normal file
@ -0,0 +1,33 @@
|
||||
// Test whether N::operator new is different from ::operator new
|
||||
#include <new>
|
||||
#include <cstdlib>
|
||||
|
||||
bool success;
|
||||
|
||||
namespace N{
|
||||
void* operator new(size_t n){
|
||||
success = true;
|
||||
return std::malloc(n);
|
||||
}
|
||||
}
|
||||
|
||||
void *operator new(size_t n)throw(std::bad_alloc)
|
||||
{
|
||||
static bool entered = false;
|
||||
if(entered)
|
||||
throw std::bad_alloc();
|
||||
entered = true;
|
||||
void *result = N::operator new(n);
|
||||
entered = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
try{
|
||||
new int;
|
||||
}catch(...){
|
||||
return 1;
|
||||
}
|
||||
return success?0:1;
|
||||
}
|
Loading…
Reference in New Issue
Block a user