11584.cc: Correct new and delete declarations, add include and test variable.
2004-01-27 Benjamin Kosnik <bkoz@redhat.com> * testsuite/27_io/ios_base/storage/11584.cc: Correct new and delete declarations, add include and test variable. From-SVN: r76766
This commit is contained in:
parent
826b47cc77
commit
62b21ea0fc
2 changed files with 31 additions and 24 deletions
|
@ -1,3 +1,8 @@
|
|||
2004-01-27 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
||||
* testsuite/27_io/ios_base/storage/11584.cc: Correct new and
|
||||
delete declarations, add include and test variable.
|
||||
|
||||
2003-01-27 Jerry Quinn <jlquinn@optonline.net>
|
||||
|
||||
* include/bits/codecvt.h, include/bits/locale_facets.h,
|
||||
|
|
|
@ -22,40 +22,42 @@
|
|||
|
||||
#include <cstdlib>
|
||||
#include <new>
|
||||
#include <iostream>
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
int new_fails;
|
||||
|
||||
void* operator new (size_t n)
|
||||
void* operator new(std::size_t n) throw (std::bad_alloc)
|
||||
{
|
||||
if (new_fails)
|
||||
throw std::bad_alloc();
|
||||
|
||||
return malloc(n);
|
||||
if (new_fails)
|
||||
throw std::bad_alloc();
|
||||
return malloc(n);
|
||||
}
|
||||
void* operator new[] (std::size_t n) throw (std::bad_alloc)
|
||||
{ return operator new(n); }
|
||||
|
||||
void operator delete (void *p) { free(p); }
|
||||
void* operator new[] (size_t n) { return operator new(n); }
|
||||
void operator delete[] (void *p) { operator delete(p); }
|
||||
void operator delete (void *p) throw() { free(p); }
|
||||
void operator delete[] (void *p) throw() { operator delete(p); }
|
||||
|
||||
int main ()
|
||||
{
|
||||
const int i = std::ios::xalloc ();
|
||||
bool test __attribute__((unused)) = true;
|
||||
const int i = std::ios::xalloc ();
|
||||
|
||||
new_fails = 1;
|
||||
|
||||
// Successive accesses to failure storage clears to zero.
|
||||
std::cout.iword(100) = 0xdeadbeef;
|
||||
VERIFY(std::cout.iword(100) == 0);
|
||||
|
||||
// Access to pword failure storage shouldn't clear iword pword storage.
|
||||
long& lr = std::cout.iword(100);
|
||||
lr = 0xdeadbeef;
|
||||
|
||||
void* pv = std::cout.pword(100);
|
||||
VERIFY(pv == 0);
|
||||
VERIFY(lr == 0xdeadbeef);
|
||||
|
||||
return 0;
|
||||
new_fails = 1;
|
||||
|
||||
// Successive accesses to failure storage clears to zero.
|
||||
std::cout.iword(100) = 0xdeadbeef;
|
||||
VERIFY(std::cout.iword(100) == 0);
|
||||
|
||||
// Access to pword failure storage shouldn't clear iword pword storage.
|
||||
long& lr = std::cout.iword(100);
|
||||
lr = 0xdeadbeef;
|
||||
|
||||
void* pv = std::cout.pword(100);
|
||||
VERIFY(pv == 0);
|
||||
VERIFY(lr == 0xdeadbeef);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue