From 62b21ea0fca95b23e9a5f3b5823ece85bea133d4 Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Tue, 27 Jan 2004 23:41:16 +0000 Subject: [PATCH] 11584.cc: Correct new and delete declarations, add include and test variable. 2004-01-27 Benjamin Kosnik * testsuite/27_io/ios_base/storage/11584.cc: Correct new and delete declarations, add include and test variable. From-SVN: r76766 --- libstdc++-v3/ChangeLog | 5 ++ .../testsuite/27_io/ios_base/storage/11584.cc | 50 ++++++++++--------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 0d037711c5bf..6fb3dd45f487 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2004-01-27 Benjamin Kosnik + + * testsuite/27_io/ios_base/storage/11584.cc: Correct new and + delete declarations, add include and test variable. + 2003-01-27 Jerry Quinn * include/bits/codecvt.h, include/bits/locale_facets.h, diff --git a/libstdc++-v3/testsuite/27_io/ios_base/storage/11584.cc b/libstdc++-v3/testsuite/27_io/ios_base/storage/11584.cc index 8b1a7a72d968..0df9c0c8b216 100644 --- a/libstdc++-v3/testsuite/27_io/ios_base/storage/11584.cc +++ b/libstdc++-v3/testsuite/27_io/ios_base/storage/11584.cc @@ -22,40 +22,42 @@ #include #include +#include #include 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; }