]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Make -fno-exceptions work.
authorBenjamin Kosnik <bkoz@redhat.com>
Wed, 24 Oct 2001 02:37:56 +0000 (02:37 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Wed, 24 Oct 2001 02:37:56 +0000 (02:37 +0000)
2001-10-23  Benjamin Kosnik  <bkoz@redhat.com>

Make -fno-exceptions work.
* config/locale/c_locale_gnu.cc: Use functexcept.
* include/bits/c++config (__stl_assert): Remove.
(__STL_USE_EXCEPTIONS): Same.
(__STL_TRY): Same.
(__STL_CATCH_ALL): Same.
(__STL_THROW): Same.
(__STL_RETHROW): Same.
(__STL_NOTHROW): Same.
(__STL_UNWIND): Same.
* include/bits/pthread_allocimpl.h: Fix.
* include/bits/std_bitset.h: Same.
* include/bits/std_list.h: Same.
* include/bits/std_memory.h: Same.
* include/bits/std_queue.h: Same.
* include/bits/stl_alloc.h: Same.
* include/bits/stl_deque.h: Same.
* include/bits/stl_list.h: Same.
* include/bits/stl_queue.h: Same.
* include/bits/stl_tempbuf.h: Same.
* include/bits/stl_tree.h: Same.
* include/bits/stl_uninitialized.h: Same.
* include/bits/stl_vector.h: Same.
* include/ext/ropeimpl.h: Same.
* include/ext/slist: Same.
* include/ext/stl_hashtable.h: Same.
* include/ext/stl_rope.h: Same.
* libsupc++/new_op.cc: Include cstdlib.
* libsupc++/eh_personality.cc: Add exception_defines include. Use
__throw_exception_again, tweak.
* libsupc++/eh_aux_runtime.cc: Include stdlib for abort.
* libsupc++/vec.cc: Tweak.
* src/functexcept.cc: Remove unused arguments.
* testsuite/23_containers/bitset_members.cc: Tweak.

From-SVN: r46455

26 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/config/locale/c_locale_gnu.cc
libstdc++-v3/include/bits/c++config
libstdc++-v3/include/bits/pthread_allocimpl.h
libstdc++-v3/include/bits/std_bitset.h
libstdc++-v3/include/bits/std_list.h
libstdc++-v3/include/bits/std_memory.h
libstdc++-v3/include/bits/std_queue.h
libstdc++-v3/include/bits/stl_alloc.h
libstdc++-v3/include/bits/stl_deque.h
libstdc++-v3/include/bits/stl_list.h
libstdc++-v3/include/bits/stl_queue.h
libstdc++-v3/include/bits/stl_tempbuf.h
libstdc++-v3/include/bits/stl_tree.h
libstdc++-v3/include/bits/stl_uninitialized.h
libstdc++-v3/include/bits/stl_vector.h
libstdc++-v3/include/ext/ropeimpl.h
libstdc++-v3/include/ext/slist
libstdc++-v3/include/ext/stl_hashtable.h
libstdc++-v3/include/ext/stl_rope.h
libstdc++-v3/libsupc++/eh_aux_runtime.cc
libstdc++-v3/libsupc++/eh_personality.cc
libstdc++-v3/libsupc++/new_op.cc
libstdc++-v3/libsupc++/vec.cc
libstdc++-v3/src/functexcept.cc
libstdc++-v3/testsuite/23_containers/bitset_members.cc

index eb56ce37dc50aaa50087467e8620fafa4e5dad38..d0ad067222fd201479ffb15d58f3942bdb9c3ce9 100644 (file)
@@ -1,3 +1,40 @@
+2001-10-23  Benjamin Kosnik  <bkoz@redhat.com>
+
+       Make -fno-exceptions work.
+       * config/locale/c_locale_gnu.cc: Use functexcept.
+       * include/bits/c++config (__stl_assert): Remove.
+       (__STL_USE_EXCEPTIONS): Same.
+       (__STL_TRY): Same.
+       (__STL_CATCH_ALL): Same.
+       (__STL_THROW): Same.
+       (__STL_RETHROW): Same.
+       (__STL_NOTHROW): Same.
+       (__STL_UNWIND): Same.
+       * include/bits/pthread_allocimpl.h: Fix.
+       * include/bits/std_bitset.h: Same.
+       * include/bits/std_list.h: Same.
+       * include/bits/std_memory.h: Same.
+       * include/bits/std_queue.h: Same.
+       * include/bits/stl_alloc.h: Same.
+       * include/bits/stl_deque.h: Same.
+       * include/bits/stl_list.h: Same.
+       * include/bits/stl_queue.h: Same.
+       * include/bits/stl_tempbuf.h: Same.
+       * include/bits/stl_tree.h: Same.
+       * include/bits/stl_uninitialized.h: Same.
+       * include/bits/stl_vector.h: Same.
+       * include/ext/ropeimpl.h: Same.
+       * include/ext/slist: Same.
+       * include/ext/stl_hashtable.h: Same.
+       * include/ext/stl_rope.h: Same.
+       * libsupc++/new_op.cc: Include cstdlib.
+       * libsupc++/eh_personality.cc: Add exception_defines include. Use
+       __throw_exception_again, tweak.
+       * libsupc++/eh_aux_runtime.cc: Include stdlib for abort.
+       * libsupc++/vec.cc: Tweak.
+       * src/functexcept.cc: Remove unused arguments.
+       * testsuite/23_containers/bitset_members.cc: Tweak.
+
 2001-10-22  Benjamin Kosnik  <bkoz@redhat.com>
 
        * config/cpu/i386/bits/limits.h: Move to...
index 3e583e0eea3424d9a18fd7a38b8d8c6f99a6b113..8b11d672d932b68ed3dd348be2a48bdd8fdd2bd3 100644 (file)
@@ -50,7 +50,7 @@ namespace std
     if (!__cloc)
       {
        // This named locale is not supported by the underlying OS.
-       throw runtime_error("attempt to create locale from unknown name");
+       __throw_runtime_error("attempt to create locale from unknown name");
       }
   }
   
index c7ee1875a949c0d225b766f26c8d472c3f222162..e1d5ae36386b1237a0a4e5f7006ca11ac11d01cb 100644 (file)
 // internal ABI change).
 #define __STL_GTHREADS
 #define __STL_THREADS
-#define __STL_VOLATILE volatile
-
-// This is also a user hook, but via -f[no-]exceptions, not direct #defines.
-#ifdef __EXCEPTIONS
-# define __STL_USE_EXCEPTIONS
-# define __STL_TRY try
-# define __STL_CATCH_ALL catch(...)
-# define __STL_THROW(x) throw x
-# define __STL_RETHROW throw
-# define __STL_NOTHROW throw()
-# define __STL_UNWIND(action) catch(...) { action; throw; }
-#else
-# define __STL_TRY 
-# define __STL_CATCH_ALL if (false)
-# define __STL_THROW(x) 
-# define __STL_RETHROW 
-# define __STL_NOTHROW 
-# define __STL_UNWIND(action) 
-#endif
 
 // Default to the typically high-speed, pool-based allocator (as
 // libstdc++-v2) instead of the malloc-based allocator (libstdc++-v3
 // The remainder of the prewritten config is mostly automatic; all the
 // user hooks are listed above.
 
-// XXX 
-// Only used in the SGI rope extensions; this is from stl_config.h and
-// should be cleaned up.
-# define __stl_assert(expr)
-
 /** @namespace std
  *  @brief Everything defined by the ISO C++ Standard is within namespace std.
  */
index 5585a3b3017c7ff0e72abae1e2ae05d67670e320..1c52127f1922416b8c812212d08522bd02e6b10a 100644 (file)
@@ -422,12 +422,12 @@ public:
     typedef pthread_allocator<_NewType> other;
   };
 
-  pthread_allocator() __STL_NOTHROW {}
-  pthread_allocator(const pthread_allocator& a) __STL_NOTHROW {}
+  pthread_allocator() throw() {}
+  pthread_allocator(const pthread_allocator& a) throw() {}
   template <class _OtherType>
        pthread_allocator(const pthread_allocator<_OtherType>&)
-               __STL_NOTHROW {}
-  ~pthread_allocator() __STL_NOTHROW {}
+               throw() {}
+  ~pthread_allocator() throw() {}
 
   pointer address(reference __x) const { return &__x; }
   const_pointer address(const_reference __x) const { return &__x; }
@@ -443,7 +443,7 @@ public:
   void deallocate(pointer __p, size_type __n)
     { _S_Alloc::deallocate(__p, __n * sizeof(_Tp)); }
 
-  size_type max_size() const __STL_NOTHROW 
+  size_type max_size() const throw() 
     { return size_t(-1) / sizeof(_Tp); }
 
   void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); }
index e70373f0ffcad40e64be1403e5dd664c9ac66fd5..d8524cac390247080122ab3a03d2780492fb6e44 100644 (file)
@@ -59,9 +59,9 @@
 #include <bits/std_cstddef.h>     // for size_t
 #include <bits/std_cstring.h>     // for memset
 #include <bits/std_string.h>
-#include <bits/std_stdexcept.h>   // for invalid_argument, out_of_range, 
-                                 // overflow_error
-
+#include <bits/std_stdexcept.h>
+#include <bits/functexcept.h>   // for invalid_argument, out_of_range, 
+                                // overflow_error
 #include <bits/std_ostream.h>     // for ostream (operator<<)
 #include <bits/std_istream.h>     // for istream (operator>>)
 
@@ -244,7 +244,7 @@ unsigned long _Base_bitset<_Nw>::_M_do_to_ulong() const
 {
   for (size_t __i = 1; __i < _Nw; ++__i) 
     if (_M_w[__i]) 
-      __STL_THROW(overflow_error("bitset"));
+      __throw_overflow_error("bitset");
   
   return _M_w[0];
 }
@@ -490,7 +490,7 @@ public:
     : _Base() 
   {
     if (__pos > __s.size()) 
-      __STL_THROW(out_of_range("bitset"));
+      __throw_out_of_range("bitset");
     _M_copy_from_string(__s, __pos,
                         basic_string<_CharT, _Traits, _Alloc>::npos);
   }
@@ -501,7 +501,7 @@ public:
     : _Base() 
   {
     if (__pos > __s.size()) 
-      __STL_THROW(out_of_range("bitset"));
+      __throw_out_of_range("bitset");
     _M_copy_from_string(__s, __pos, __n);
   }
 
@@ -577,7 +577,7 @@ public:
 
   bitset<_Nb>& set(size_t __pos, bool __val = true) {
     if (__pos >= _Nb)
-      __STL_THROW(out_of_range("bitset"));
+      __throw_out_of_range("bitset");
 
     return _Unchecked_set(__pos, __val);
   }
@@ -589,7 +589,7 @@ public:
 
   bitset<_Nb>& reset(size_t __pos) {
     if (__pos >= _Nb)
-      __STL_THROW(out_of_range("bitset"));
+      __throw_out_of_range("bitset");
 
     return _Unchecked_reset(__pos);
   }
@@ -602,7 +602,7 @@ public:
 
   bitset<_Nb>& flip(size_t __pos) {
     if (__pos >= _Nb)
-      __STL_THROW(out_of_range("bitset"));
+      __throw_out_of_range("bitset");
 
     return _Unchecked_flip(__pos);
   }
@@ -650,7 +650,7 @@ public:
 
   bool test(size_t __pos) const {
     if (__pos >= _Nb)
-      __STL_THROW(out_of_range("bitset"));
+      __throw_out_of_range("bitset");
 
     return _Unchecked_test(__pos);
   }
@@ -700,7 +700,7 @@ void bitset<_Nb>
       set(__i);
       break;
     default:
-      __STL_THROW(invalid_argument("bitset"));
+      __throw_invalid_argument("bitset");
     }
   }
 }
index 98224057678db8f66c7ffb29936ae09f90a2836e..e34734d1d449461f2b585de902208ff41b65e20d 100644 (file)
@@ -58,6 +58,7 @@
 
 #pragma GCC system_header
 
+#include <bits/functexcept.h>
 #include <bits/stl_algobase.h>
 #include <bits/stl_alloc.h>
 #include <bits/stl_construct.h>
index fa9c90dc32371e9351f4459c78ce8896ff3c7dd9..1aab9ffe13f4e3fe8a91c978fb12a611db10bd14 100644 (file)
@@ -69,19 +69,19 @@ private:
 public:
   typedef _Tp element_type;
 
-  explicit auto_ptr(_Tp* __p = 0) __STL_NOTHROW : _M_ptr(__p) {}
-  auto_ptr(auto_ptr& __a) __STL_NOTHROW : _M_ptr(__a.release()) {}
+  explicit auto_ptr(_Tp* __p = 0) throw() : _M_ptr(__p) {}
+  auto_ptr(auto_ptr& __a) throw() : _M_ptr(__a.release()) {}
 
-  template <class _Tp1> auto_ptr(auto_ptr<_Tp1>& __a) __STL_NOTHROW
+  template <class _Tp1> auto_ptr(auto_ptr<_Tp1>& __a) throw()
     : _M_ptr(__a.release()) {}
 
-  auto_ptr& operator=(auto_ptr& __a) __STL_NOTHROW {
+  auto_ptr& operator=(auto_ptr& __a) throw() {
     reset(__a.release());
     return *this;
   }
 
   template <class _Tp1>
-  auto_ptr& operator=(auto_ptr<_Tp1>& __a) __STL_NOTHROW {
+  auto_ptr& operator=(auto_ptr<_Tp1>& __a) throw() {
     reset(__a.release());
     return *this;
   }
@@ -92,21 +92,21 @@ public:
   // this is prohibited.
   ~auto_ptr() { delete _M_ptr; }
  
-  _Tp& operator*() const __STL_NOTHROW {
+  _Tp& operator*() const throw() {
     return *_M_ptr;
   }
-  _Tp* operator->() const __STL_NOTHROW {
+  _Tp* operator->() const throw() {
     return _M_ptr;
   }
-  _Tp* get() const __STL_NOTHROW {
+  _Tp* get() const throw() {
     return _M_ptr;
   }
-  _Tp* release() __STL_NOTHROW {
+  _Tp* release() throw() {
     _Tp* __tmp = _M_ptr;
     _M_ptr = 0;
     return __tmp;
   }
-  void reset(_Tp* __p = 0) __STL_NOTHROW {
+  void reset(_Tp* __p = 0) throw() {
     if (__p != _M_ptr) {
       delete _M_ptr;
       _M_ptr = __p;
@@ -118,10 +118,10 @@ public:
   // in fact, most present-day compilers do not support the language 
   // features that these conversions rely on.
 public:
-  auto_ptr(auto_ptr_ref<_Tp> __ref) __STL_NOTHROW
+  auto_ptr(auto_ptr_ref<_Tp> __ref) throw()
     : _M_ptr(__ref._M_ptr) {}
 
-  auto_ptr& operator=(auto_ptr_ref<_Tp> __ref) __STL_NOTHROW {
+  auto_ptr& operator=(auto_ptr_ref<_Tp> __ref) throw() {
     if (__ref._M_ptr != this->get()) {
       delete _M_ptr;
       _M_ptr = __ref._M_ptr;
@@ -129,9 +129,9 @@ public:
     return *this;
   }
 
-  template <class _Tp1> operator auto_ptr_ref<_Tp1>() __STL_NOTHROW 
+  template <class _Tp1> operator auto_ptr_ref<_Tp1>() throw() 
     { return auto_ptr_ref<_Tp>(this->release()); }
-  template <class _Tp1> operator auto_ptr<_Tp1>() __STL_NOTHROW
+  template <class _Tp1> operator auto_ptr<_Tp1>() throw()
     { return auto_ptr<_Tp1>(this->release()); }
 };
 
index 88a7803539fa1a7396e5a6f93eb8ab914be00341..87dc80a98c019df6077cf80aa3b5323ff725bc0b 100644 (file)
@@ -58,6 +58,7 @@
 
 #pragma GCC system_header
 #include <bits/c++config.h>
+#include <bits/functexcept.h>
 #include <bits/stl_algobase.h>
 #include <bits/stl_alloc.h>
 #include <bits/stl_construct.h>
index 3582212576f2911d845180cf74833c50adc4f240..c0a9a46197b930fae97ef747dcef69396e036187 100644 (file)
@@ -306,7 +306,7 @@ private:
         char _M_client_data[1];    /* The client sees this.        */
   };
 
-  static _Obj* __STL_VOLATILE _S_free_list[]; 
+  static _Obj* volatile _S_free_list[]; 
         // Specifying a size results in duplicate def for 4.1
   static  size_t _S_freelist_index(size_t __bytes) {
         return (((__bytes) + (size_t)_ALIGN-1)/(size_t)_ALIGN - 1);
@@ -349,7 +349,7 @@ public:
       __ret = __mem_interface::allocate(__n);
     else 
       {
-       _Obj* __STL_VOLATILE* __my_free_list = _S_free_list + _S_freelist_index(__n);
+       _Obj* volatile* __my_free_list = _S_free_list + _S_freelist_index(__n);
        // Acquire the lock here with a constructor call.
        // This ensures that it is released in exit or during stack
        // unwinding.
@@ -377,7 +377,7 @@ public:
       __mem_interface::deallocate(__p, __n);
     else 
       {
-       _Obj* __STL_VOLATILE*  __my_free_list
+       _Obj* volatile*  __my_free_list
           = _S_free_list + _S_freelist_index(__n);
        _Obj* __q = (_Obj*)__p;
        
@@ -448,7 +448,7 @@ __default_alloc_template<__threads, __inst>::_S_chunk_alloc(size_t __size,
         // Try to make use of the left-over piece.
         if (__bytes_left > 0) 
          {
-           _Obj* __STL_VOLATILE* __my_free_list =
+           _Obj* volatile* __my_free_list =
              _S_free_list + _S_freelist_index(__bytes_left);
            
            ((_Obj*)_S_start_free) -> _M_free_list_link = *__my_free_list;
@@ -458,7 +458,7 @@ __default_alloc_template<__threads, __inst>::_S_chunk_alloc(size_t __size,
         if (0 == _S_start_free) 
          {
             size_t __i;
-            _Obj* __STL_VOLATILE* __my_free_list;
+            _Obj* volatile* __my_free_list;
            _Obj* __p;
             // Try to make do with what we have.  That can't hurt.  We
             // do not try smaller requests, since that tends to result
@@ -500,7 +500,7 @@ __default_alloc_template<__threads, __inst>::_S_refill(size_t __n)
 {
     int __nobjs = 20;
     char* __chunk = _S_chunk_alloc(__n, __nobjs);
-    _Obj* __STL_VOLATILE* __my_free_list;
+    _Obj* volatile* __my_free_list;
     _Obj* __result;
     _Obj* __current_obj;
     _Obj* __next_obj;
@@ -563,7 +563,7 @@ template <bool __threads, int __inst>
 size_t __default_alloc_template<__threads, __inst>::_S_heap_size = 0;
 
 template <bool __threads, int __inst>
-typename __default_alloc_template<__threads, __inst>::_Obj* __STL_VOLATILE
+typename __default_alloc_template<__threads, __inst>::_Obj* volatile
 __default_alloc_template<__threads, __inst> ::_S_free_list[
     __default_alloc_template<__threads, __inst>::_NFREELISTS
 ] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
@@ -597,10 +597,10 @@ public:
     typedef allocator<_Tp1> other;
   };
 
-  allocator() __STL_NOTHROW {}
-  allocator(const allocator&) __STL_NOTHROW {}
-  template <class _Tp1> allocator(const allocator<_Tp1>&) __STL_NOTHROW {}
-  ~allocator() __STL_NOTHROW {}
+  allocator() throw() {}
+  allocator(const allocator&) throw() {}
+  template <class _Tp1> allocator(const allocator<_Tp1>&) throw() {}
+  ~allocator() throw() {}
 
   pointer address(reference __x) const { return &__x; }
   const_pointer address(const_reference __x) const { return &__x; }
@@ -616,7 +616,7 @@ public:
   void deallocate(pointer __p, size_type __n)
     { _Alloc::deallocate(__p, __n * sizeof(_Tp)); }
 
-  size_type max_size() const __STL_NOTHROW 
+  size_type max_size() const throw() 
     { return size_t(-1) / sizeof(_Tp); }
 
   void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); }
@@ -673,13 +673,13 @@ struct __allocator {
     typedef __allocator<_Tp1, _Alloc> other;
   };
 
-  __allocator() __STL_NOTHROW {}
-  __allocator(const __allocator& __a) __STL_NOTHROW
+  __allocator() throw() {}
+  __allocator(const __allocator& __a) throw()
     : __underlying_alloc(__a.__underlying_alloc) {}
   template <class _Tp1> 
-  __allocator(const __allocator<_Tp1, _Alloc>& __a) __STL_NOTHROW
+  __allocator(const __allocator<_Tp1, _Alloc>& __a) throw()
     : __underlying_alloc(__a.__underlying_alloc) {}
-  ~__allocator() __STL_NOTHROW {}
+  ~__allocator() throw() {}
 
   pointer address(reference __x) const { return &__x; }
   const_pointer address(const_reference __x) const { return &__x; }
@@ -695,7 +695,7 @@ struct __allocator {
   void deallocate(pointer __p, size_type __n)
     { __underlying_alloc.deallocate(__p, __n * sizeof(_Tp)); }
 
-  size_type max_size() const __STL_NOTHROW 
+  size_type max_size() const throw() 
     { return size_t(-1) / sizeof(_Tp); }
 
   void construct(pointer __p, const _Tp& __val) { new(__p) _Tp(__val); }
index a361756d1fd1d746dc8c2a411cd634a250fe6e4f..1024252ddfabe13276ce662465059d0a8658cd30 100644 (file)
 
 namespace std
 { 
-
-// Note: this function is simply a kludge to work around several compilers'
-//  bugs in handling constant expressions.
-inline size_t __deque_buf_size(size_t __size) {
-  return __size < 512 ? size_t(512 / __size) : size_t(1);
-}
-
-template <class _Tp, class _Ref, class _Ptr>
-struct _Deque_iterator {
+  // Note: this function is simply a kludge to work around several compilers'
+  //  bugs in handling constant expressions.
+  inline size_t 
+  __deque_buf_size(size_t __size) 
+  { return __size < 512 ? size_t(512 / __size) : size_t(1); }
+
+  template <class _Tp, class _Ref, class _Ptr>
+  struct _Deque_iterator {
   typedef _Deque_iterator<_Tp, _Tp&, _Tp*>             iterator;
   typedef _Deque_iterator<_Tp, const _Tp&, const _Tp*> const_iterator;
   static size_t _S_buffer_size() { return __deque_buf_size(sizeof(_Tp)); }
@@ -351,11 +350,16 @@ _Deque_base<_Tp,_Alloc>::_M_initialize_map(size_t __num_elements)
   _Tp** __nstart = _M_map + (_M_map_size - __num_nodes) / 2;
   _Tp** __nfinish = __nstart + __num_nodes;
     
-  __STL_TRY {
-    _M_create_nodes(__nstart, __nfinish);
-  }
-  __STL_UNWIND((_M_deallocate_map(_M_map, _M_map_size), 
-                _M_map = 0, _M_map_size = 0));
+  try 
+    { _M_create_nodes(__nstart, __nfinish); }
+  catch(...)
+    {
+      _M_deallocate_map(_M_map, _M_map_size);
+      _M_map = 0;
+      _M_map_size = 0;
+      __throw_exception_again;
+    }
+  
   _M_start._M_set_node(__nstart);
   _M_finish._M_set_node(__nfinish - 1);
   _M_start._M_cur = _M_start._M_first;
@@ -367,11 +371,15 @@ template <class _Tp, class _Alloc>
 void _Deque_base<_Tp,_Alloc>::_M_create_nodes(_Tp** __nstart, _Tp** __nfinish)
 {
   _Tp** __cur;
-  __STL_TRY {
+  try {
     for (__cur = __nstart; __cur < __nfinish; ++__cur)
       *__cur = _M_allocate_node();
   }
-  __STL_UNWIND(_M_destroy_nodes(__nstart, __cur));
+  catch(...)
+    { 
+      _M_destroy_nodes(__nstart, __cur);
+      __throw_exception_again; 
+    }
 }
 
 template <class _Tp, class _Alloc>
@@ -850,20 +858,27 @@ void deque<_Tp, _Alloc>::_M_fill_insert(iterator __pos,
 {
   if (__pos._M_cur == _M_start._M_cur) {
     iterator __new_start = _M_reserve_elements_at_front(__n);
-    __STL_TRY {
+    try {
       uninitialized_fill(__new_start, _M_start, __x);
       _M_start = __new_start;
     }
-    __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node));
+    catch(...)
+      {
+       _M_destroy_nodes(__new_start._M_node, _M_start._M_node);
+       __throw_exception_again;
+      }
   }
   else if (__pos._M_cur == _M_finish._M_cur) {
     iterator __new_finish = _M_reserve_elements_at_back(__n);
-    __STL_TRY {
+    try {
       uninitialized_fill(_M_finish, __new_finish, __x);
       _M_finish = __new_finish;
     }
-    __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, 
-                                  __new_finish._M_node + 1));    
+    catch(...)
+      {
+       _M_destroy_nodes(_M_finish._M_node + 1, __new_finish._M_node + 1);    
+       __throw_exception_again;
+      }
   }
   else 
     _M_insert_aux(__pos, __n, __x);
@@ -924,12 +939,16 @@ void deque<_Tp,_Alloc>::clear()
 template <class _Tp, class _Alloc>
 void deque<_Tp,_Alloc>::_M_fill_initialize(const value_type& __value) {
   _Map_pointer __cur;
-  __STL_TRY {
+  try {
     for (__cur = _M_start._M_node; __cur < _M_finish._M_node; ++__cur)
       uninitialized_fill(*__cur, *__cur + _S_buffer_size(), __value);
     uninitialized_fill(_M_finish._M_first, _M_finish._M_cur, __value);
   }
-  __STL_UNWIND(_Destroy(_M_start, iterator(*__cur, __cur)));
+  catch(...)
+    {
+      _Destroy(_M_start, iterator(*__cur, __cur));
+      __throw_exception_again;
+    }
 }
 
 template <class _Tp, class _Alloc> template <class _InputIterator>
@@ -938,11 +957,15 @@ void deque<_Tp,_Alloc>::_M_range_initialize(_InputIterator __first,
                                             input_iterator_tag)
 {
   _M_initialize_map(0);
-  __STL_TRY {
+  try {
     for ( ; __first != __last; ++__first)
       push_back(*__first);
   }
-  __STL_UNWIND(clear());
+  catch(...)
+    {
+      clear();
+      __throw_exception_again;
+    }
 }
 
 template <class _Tp, class _Alloc> template <class _ForwardIterator>
@@ -955,7 +978,7 @@ void deque<_Tp,_Alloc>::_M_range_initialize(_ForwardIterator __first,
   _M_initialize_map(__n);
 
   _Map_pointer __cur_node;
-  __STL_TRY {
+  try {
     for (__cur_node = _M_start._M_node; 
          __cur_node < _M_finish._M_node; 
          ++__cur_node) {
@@ -966,7 +989,11 @@ void deque<_Tp,_Alloc>::_M_range_initialize(_ForwardIterator __first,
     }
     uninitialized_copy(__first, __last, _M_finish._M_first);
   }
-  __STL_UNWIND(_Destroy(_M_start, iterator(*__cur_node, __cur_node)));
+  catch(...)
+    {
+      _Destroy(_M_start, iterator(*__cur_node, __cur_node));
+      __throw_exception_again;
+    }
 }
 
 // Called only if _M_finish._M_cur == _M_finish._M_last - 1.
@@ -977,12 +1004,16 @@ deque<_Tp,_Alloc>::_M_push_back_aux(const value_type& __t)
   value_type __t_copy = __t;
   _M_reserve_map_at_back();
   *(_M_finish._M_node + 1) = _M_allocate_node();
-  __STL_TRY {
+  try {
     _Construct(_M_finish._M_cur, __t_copy);
     _M_finish._M_set_node(_M_finish._M_node + 1);
     _M_finish._M_cur = _M_finish._M_first;
   }
-  __STL_UNWIND(_M_deallocate_node(*(_M_finish._M_node + 1)));
+  catch(...)
+    {
+      _M_deallocate_node(*(_M_finish._M_node + 1));
+      __throw_exception_again;
+    }
 }
 
 // Called only if _M_finish._M_cur == _M_finish._M_last - 1.
@@ -992,12 +1023,16 @@ deque<_Tp,_Alloc>::_M_push_back_aux()
 {
   _M_reserve_map_at_back();
   *(_M_finish._M_node + 1) = _M_allocate_node();
-  __STL_TRY {
+  try {
     _Construct(_M_finish._M_cur);
     _M_finish._M_set_node(_M_finish._M_node + 1);
     _M_finish._M_cur = _M_finish._M_first;
   }
-  __STL_UNWIND(_M_deallocate_node(*(_M_finish._M_node + 1)));
+  catch(...)
+    {
+      _M_deallocate_node(*(_M_finish._M_node + 1));
+      __throw_exception_again;
+    }
 }
 
 // Called only if _M_start._M_cur == _M_start._M_first.
@@ -1008,12 +1043,17 @@ deque<_Tp,_Alloc>::_M_push_front_aux(const value_type& __t)
   value_type __t_copy = __t;
   _M_reserve_map_at_front();
   *(_M_start._M_node - 1) = _M_allocate_node();
-  __STL_TRY {
+  try {
     _M_start._M_set_node(_M_start._M_node - 1);
     _M_start._M_cur = _M_start._M_last - 1;
     _Construct(_M_start._M_cur, __t_copy);
   }
-  __STL_UNWIND((++_M_start, _M_deallocate_node(*(_M_start._M_node - 1))));
+  catch(...)
+    {
+      ++_M_start;
+      _M_deallocate_node(*(_M_start._M_node - 1));
+      __throw_exception_again;
+    }
 } 
 
 // Called only if _M_start._M_cur == _M_start._M_first.
@@ -1023,12 +1063,17 @@ deque<_Tp,_Alloc>::_M_push_front_aux()
 {
   _M_reserve_map_at_front();
   *(_M_start._M_node - 1) = _M_allocate_node();
-  __STL_TRY {
+  try {
     _M_start._M_set_node(_M_start._M_node - 1);
     _M_start._M_cur = _M_start._M_last - 1;
     _Construct(_M_start._M_cur);
   }
-  __STL_UNWIND((++_M_start, _M_deallocate_node(*(_M_start._M_node - 1))));
+  catch(...)
+    {
+      ++_M_start;
+      _M_deallocate_node(*(_M_start._M_node - 1));
+      __throw_exception_again;
+    }
 } 
 
 // Called only if _M_finish._M_cur == _M_finish._M_first.
@@ -1071,20 +1116,27 @@ deque<_Tp,_Alloc>::insert(iterator __pos,
   distance(__first, __last, __n);
   if (__pos._M_cur == _M_start._M_cur) {
     iterator __new_start = _M_reserve_elements_at_front(__n);
-    __STL_TRY {
+    try {
       uninitialized_copy(__first, __last, __new_start);
       _M_start = __new_start;
     }
-    __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node));
+    catch(...)
+      {
+       _M_destroy_nodes(__new_start._M_node, _M_start._M_node);
+       __throw_exception_again;
+      }
   }
   else if (__pos._M_cur == _M_finish._M_cur) {
     iterator __new_finish = _M_reserve_elements_at_back(__n);
-    __STL_TRY {
+    try {
       uninitialized_copy(__first, __last, _M_finish);
       _M_finish = __new_finish;
     }
-    __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, 
-                                  __new_finish._M_node + 1));
+    catch(...)
+      {
+       _M_destroy_nodes(_M_finish._M_node + 1, __new_finish._M_node + 1);
+       __throw_exception_again;
+      }
   }
   else
     _M_insert_aux(__pos, __first, __last, __n);
@@ -1161,7 +1213,7 @@ void deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos,
     iterator __new_start = _M_reserve_elements_at_front(__n);
     iterator __old_start = _M_start;
     __pos = _M_start + __elems_before;
-    __STL_TRY {
+    try {
       if (__elems_before >= difference_type(__n)) {
         iterator __start_n = _M_start + difference_type(__n);
         uninitialized_copy(_M_start, __start_n, __new_start);
@@ -1176,7 +1228,11 @@ void deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos,
         fill(__old_start, __pos, __x_copy);
       }
     }
-    __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node));
+    catch(...)
+      { 
+       _M_destroy_nodes(__new_start._M_node, _M_start._M_node);
+       __throw_exception_again;
+      }
   }
   else {
     iterator __new_finish = _M_reserve_elements_at_back(__n);
@@ -1184,7 +1240,7 @@ void deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos,
     const difference_type __elems_after = 
       difference_type(__length) - __elems_before;
     __pos = _M_finish - __elems_after;
-    __STL_TRY {
+    try {
       if (__elems_after > difference_type(__n)) {
         iterator __finish_n = _M_finish - difference_type(__n);
         uninitialized_copy(__finish_n, _M_finish, _M_finish);
@@ -1199,8 +1255,11 @@ void deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos,
         fill(__pos, __old_finish, __x_copy);
       }
     }
-    __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, 
-                                  __new_finish._M_node + 1));
+    catch(...)
+      { 
+       _M_destroy_nodes(_M_finish._M_node + 1, __new_finish._M_node + 1);
+       __throw_exception_again;
+      }
   }
 }
 
@@ -1216,7 +1275,7 @@ void deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos,
     iterator __new_start = _M_reserve_elements_at_front(__n);
     iterator __old_start = _M_start;
     __pos = _M_start + __elemsbefore;
-    __STL_TRY {
+    try {
       if (__elemsbefore >= difference_type(__n)) {
         iterator __start_n = _M_start + difference_type(__n); 
         uninitialized_copy(_M_start, __start_n, __new_start);
@@ -1233,7 +1292,11 @@ void deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos,
         copy(__mid, __last, __old_start);
       }
     }
-    __STL_UNWIND(_M_destroy_nodes(__new_start._M_node, _M_start._M_node));
+    catch(...)
+      {
+       _M_destroy_nodes(__new_start._M_node, _M_start._M_node);
+       __throw_exception_again;
+      }
   }
   else {
     iterator __new_finish = _M_reserve_elements_at_back(__n);
@@ -1241,7 +1304,7 @@ void deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos,
     const difference_type __elemsafter = 
       difference_type(__length) - __elemsbefore;
     __pos = _M_finish - __elemsafter;
-    __STL_TRY {
+    try {
       if (__elemsafter > difference_type(__n)) {
         iterator __finish_n = _M_finish - difference_type(__n);
         uninitialized_copy(__finish_n, _M_finish, _M_finish);
@@ -1257,8 +1320,11 @@ void deque<_Tp,_Alloc>::_M_insert_aux(iterator __pos,
         copy(__first, __mid, __pos);
       }
     }
-    __STL_UNWIND(_M_destroy_nodes(_M_finish._M_node + 1, 
-                                  __new_finish._M_node + 1));
+    catch(...)
+      {
+       _M_destroy_nodes(_M_finish._M_node + 1, __new_finish._M_node + 1);
+       __throw_exception_again;
+      }
   }
 }
 
@@ -1269,17 +1335,15 @@ void deque<_Tp,_Alloc>::_M_new_elements_at_front(size_type __new_elems)
       = (__new_elems + _S_buffer_size() - 1) / _S_buffer_size();
   _M_reserve_map_at_front(__new_nodes);
   size_type __i;
-  __STL_TRY {
+  try {
     for (__i = 1; __i <= __new_nodes; ++__i)
       *(_M_start._M_node - __i) = _M_allocate_node();
   }
-#       ifdef __STL_USE_EXCEPTIONS
   catch(...) {
     for (size_type __j = 1; __j < __i; ++__j)
       _M_deallocate_node(*(_M_start._M_node - __j));      
     throw;
   }
-#       endif /* __STL_USE_EXCEPTIONS */
 }
 
 template <class _Tp, class _Alloc>
@@ -1289,17 +1353,15 @@ void deque<_Tp,_Alloc>::_M_new_elements_at_back(size_type __new_elems)
       = (__new_elems + _S_buffer_size() - 1) / _S_buffer_size();
   _M_reserve_map_at_back(__new_nodes);
   size_type __i;
-  __STL_TRY {
+  try {
     for (__i = 1; __i <= __new_nodes; ++__i)
       *(_M_finish._M_node + __i) = _M_allocate_node();
   }
-#       ifdef __STL_USE_EXCEPTIONS
   catch(...) {
     for (size_type __j = 1; __j < __i; ++__j)
       _M_deallocate_node(*(_M_finish._M_node + __j));      
     throw;
   }
-#       endif /* __STL_USE_EXCEPTIONS */
 }
 
 template <class _Tp, class _Alloc>
index 7e9ad8f307b9969a56849b1912de4ccf49f4d149..275699e94d35a5de7453edab5fab349b6eb70de7 100644 (file)
@@ -265,20 +265,28 @@ protected:
   _Node* _M_create_node(const _Tp& __x)
   {
     _Node* __p = _M_get_node();
-    __STL_TRY {
+    try {
       _Construct(&__p->_M_data, __x);
     }
-    __STL_UNWIND(_M_put_node(__p));
+    catch(...)
+      { 
+       _M_put_node(__p);
+       __throw_exception_again; 
+      }
     return __p;
   }
 
   _Node* _M_create_node()
   {
     _Node* __p = _M_get_node();
-    __STL_TRY {
+    try {
       _Construct(&__p->_M_data);
     }
-    __STL_UNWIND(_M_put_node(__p));
+    catch(...)
+      { 
+       _M_put_node(__p);
+       __throw_exception_again; 
+      }
     return __p;
   }
 
index 1538ca2a977c1f4e6a515932d08bb5dc2f11be2e..7bf33c1314b4cf8ae60873e0aa51c73adc329e87 100644 (file)
@@ -200,19 +200,35 @@ public:
   bool empty() const { return c.empty(); }
   size_type size() const { return c.size(); }
   const_reference top() const { return c.front(); }
-  void push(const value_type& __x) {
-    __STL_TRY {
-      c.push_back(__x); 
-      push_heap(c.begin(), c.end(), comp);
-    }
-    __STL_UNWIND(c.clear());
+
+  void 
+  push(const value_type& __x) 
+  {
+    try 
+      {
+       c.push_back(__x); 
+       push_heap(c.begin(), c.end(), comp);
+      }
+    catch(...)
+      {
+       c.clear();
+       __throw_exception_again; 
+      }
   }
-  void pop() {
-    __STL_TRY {
-      pop_heap(c.begin(), c.end(), comp);
-      c.pop_back();
-    }
-    __STL_UNWIND(c.clear());
+
+  void 
+  pop() 
+  {
+    try 
+      {
+       pop_heap(c.begin(), c.end(), comp);
+       c.pop_back();
+      }
+    catch(...)
+      {
+       c.clear();
+       __throw_exception_again; 
+      }
   }
 };
 
index f6c9a529142a142ae4c31c01f5abc66adcbc9dde..f6b154f585463addd3a40900e3390ab7cfa7ae44 100644 (file)
@@ -138,14 +138,20 @@ public:
     typedef typename __type_traits<_Tp>::has_trivial_default_constructor
             _Trivial;
 
-    __STL_TRY {
+    try {
       _M_len = 0;
       distance(__first, __last, _M_len);
       _M_allocate_buffer();
       if (_M_len > 0)
         _M_initialize_buffer(*__first, _Trivial());
     }
-    __STL_UNWIND(free(_M_buffer); _M_buffer = 0; _M_len = 0);
+    catch(...)
+      { 
+       free(_M_buffer); 
+       _M_buffer = 0; 
+       _M_len = 0;
+       __throw_exception_again; 
+      }
   }
  
   ~_Temporary_buffer() {  
index 446cce0d3ec75a6c7892ab584a23586b3ea7e4bd..87dc603c6ec13c4c76c80ca373a09f79c769b95f 100644 (file)
@@ -556,10 +556,14 @@ protected:
   _M_create_node(const value_type& __x)
   {
     _Link_type __tmp = _M_get_node();
-    __STL_TRY {
+    try {
       _Construct(&__tmp->_M_value_field, __x);
     }
-    __STL_UNWIND(_M_put_node(__tmp));
+    catch(...)
+      {
+       _M_put_node(__tmp);
+       __throw_exception_again; 
+      }
     return __tmp;
   }
 
@@ -1032,7 +1036,7 @@ _Rb_tree<_Key,_Val,_KoV,_Compare,_Alloc>
   _Link_type __top = _M_clone_node(__x);
   __top->_M_parent = __p;
  
-  __STL_TRY {
+  try {
     if (__x->_M_right)
       __top->_M_right = _M_copy(_S_right(__x), __top);
     __p = __top;
@@ -1048,8 +1052,11 @@ _Rb_tree<_Key,_Val,_KoV,_Compare,_Alloc>
       __x = _S_left(__x);
     }
   }
-  __STL_UNWIND(_M_erase(__top));
-
+  catch(...)
+    {
+      _M_erase(__top);
+      __throw_exception_again; 
+    }
   return __top;
 }
 
index f62364098bf9241d5ec9ac39967d6bcfaa712be0..383e0842179865e35830c87d1e58cb0ebd59f7ab 100644 (file)
@@ -81,12 +81,16 @@ namespace std
                             __false_type)
     {
       _ForwardIter __cur = __result;
-      __STL_TRY {
+      try {
        for ( ; __first != __last; ++__first, ++__cur)
          _Construct(&*__cur, *__first);
        return __cur;
       }
-      __STL_UNWIND(_Destroy(__result, __cur));
+      catch(...)
+       {
+         _Destroy(__result, __cur);
+         __throw_exception_again; 
+       }
     }
 
   template<typename _InputIter, typename _ForwardIter>
@@ -122,12 +126,16 @@ namespace std
                           input_iterator_tag)
     {
       _ForwardIter __cur = __result;
-      __STL_TRY {
+      try {
        for ( ; __count > 0 ; --__count, ++__first, ++__cur) 
          _Construct(&*__cur, *__first);
        return pair<_InputIter, _ForwardIter>(__first, __cur);
       }
-      __STL_UNWIND(_Destroy(__result, __cur));
+      catch(...)
+       {
+         _Destroy(__result, __cur);
+         __throw_exception_again; 
+       }
     }
 
   template<typename _RandomAccessIter, typename _Size, typename _ForwardIter>
@@ -172,11 +180,15 @@ namespace std
                             const _Tp& __x, __false_type)
     {
       _ForwardIter __cur = __first;
-      __STL_TRY {
+      try {
        for ( ; __cur != __last; ++__cur)
          _Construct(&*__cur, __x);
       }
-      __STL_UNWIND(_Destroy(__first, __cur));
+      catch(...)
+       {
+         _Destroy(__first, __cur);
+         __throw_exception_again; 
+       }
     }
 
   template<typename _ForwardIter, typename _Tp>
@@ -204,12 +216,16 @@ namespace std
                               const _Tp& __x, __false_type)
     {
       _ForwardIter __cur = __first;
-      __STL_TRY {
+      try {
        for ( ; __n > 0; --__n, ++__cur)
          _Construct(&*__cur, __x);
        return __cur;
       }
-      __STL_UNWIND(_Destroy(__first, __cur));
+      catch(...)
+       { 
+         _Destroy(__first, __cur);
+         __throw_exception_again; 
+       }
     }
 
   template<typename _ForwardIter, typename _Size, typename _Tp>
@@ -236,10 +252,14 @@ namespace std
                              _ForwardIter __result)
     {
       _ForwardIter __mid = uninitialized_copy(__first1, __last1, __result);
-      __STL_TRY {
+      try {
        return uninitialized_copy(__first2, __last2, __mid);
       }
-      __STL_UNWIND(_Destroy(__result, __mid));
+      catch(...)
+       { 
+         _Destroy(__result, __mid);
+         __throw_exception_again; 
+       }
     }
 
   // __uninitialized_fill_copy
@@ -252,10 +272,14 @@ namespace std
                              _InputIter __first, _InputIter __last)
     {
       uninitialized_fill(__result, __mid, __x);
-      __STL_TRY {
+      try {
        return uninitialized_copy(__first, __last, __mid);
       }
-      __STL_UNWIND(_Destroy(__result, __mid));
+      catch(...)
+       {
+         _Destroy(__result, __mid);
+         __throw_exception_again; 
+       }
     }
 
   // __uninitialized_copy_fill
@@ -268,10 +292,14 @@ namespace std
                              const _Tp& __x)
     {
       _ForwardIter __mid2 = uninitialized_copy(__first1, __last1, __first2);
-      __STL_TRY {
+      try {
        uninitialized_fill(__mid2, __last2, __x);
       }
-      __STL_UNWIND(_Destroy(__first2, __mid2));
+      catch(...)
+       {
+         _Destroy(__first2, __mid2);
+         __throw_exception_again; 
+       }
     }
 
 } // namespace std
index 14f596b9e711dd99cde1ffa45a560b2ba02e92e2..8237c3e23b1ceb0f3e6223385c83ed9711e81c05 100644 (file)
@@ -437,11 +437,15 @@ protected:
                                                _ForwardIterator __last)
   {
     pointer __result = _M_allocate(__n);
-    __STL_TRY {
+    try {
       uninitialized_copy(__first, __last, __result);
       return __result;
     }
-    __STL_UNWIND(_M_deallocate(__result, __n));
+    catch(...)
+      { 
+       _M_deallocate(__result, __n);
+       __throw_exception_again;
+      }
   }
 
   template <class _InputIterator>
@@ -617,7 +621,7 @@ vector<_Tp, _Alloc>::_M_insert_aux(iterator __position, const _Tp& __x)
     const size_type __len = __old_size != 0 ? 2 * __old_size : 1;
     iterator __new_start(_M_allocate(__len));
     iterator __new_finish(__new_start);
-    __STL_TRY {
+    try {
       __new_finish = uninitialized_copy(iterator(_M_start), __position,
                                         __new_start);
       _Construct(__new_finish.base(), __x);
@@ -625,8 +629,12 @@ vector<_Tp, _Alloc>::_M_insert_aux(iterator __position, const _Tp& __x)
       __new_finish = uninitialized_copy(__position, iterator(_M_finish),
                                         __new_finish);
     }
-    __STL_UNWIND((_Destroy(__new_start,__new_finish), 
-                  _M_deallocate(__new_start.base(),__len)));
+    catch(...)
+      { 
+       _Destroy(__new_start,__new_finish); 
+       _M_deallocate(__new_start.base(),__len);
+       __throw_exception_again;
+      }
     _Destroy(begin(), end());
     _M_deallocate(_M_start, _M_end_of_storage - _M_start);
     _M_start = __new_start.base();
@@ -651,7 +659,7 @@ vector<_Tp, _Alloc>::_M_insert_aux(iterator __position)
     const size_type __len = __old_size != 0 ? 2 * __old_size : 1;
     pointer __new_start = _M_allocate(__len);
     pointer __new_finish = __new_start;
-    __STL_TRY {
+    try {
       __new_finish = uninitialized_copy(iterator(_M_start), __position, 
                                        __new_start);
       _Construct(__new_finish);
@@ -659,8 +667,12 @@ vector<_Tp, _Alloc>::_M_insert_aux(iterator __position)
       __new_finish = uninitialized_copy(__position, iterator(_M_finish), 
                                        __new_finish);
     }
-    __STL_UNWIND((_Destroy(__new_start,__new_finish), 
-                  _M_deallocate(__new_start,__len)));
+    catch(...)
+      {
+       _Destroy(__new_start,__new_finish); 
+       _M_deallocate(__new_start,__len);
+       __throw_exception_again;
+      }
     _Destroy(begin(), end());
     _M_deallocate(_M_start, _M_end_of_storage - _M_start);
     _M_start = __new_start;
@@ -697,14 +709,18 @@ void vector<_Tp, _Alloc>::_M_fill_insert(iterator __position, size_type __n,
       const size_type __len = __old_size + max(__old_size, __n);
       iterator __new_start(_M_allocate(__len));
       iterator __new_finish(__new_start);
-      __STL_TRY {
+      try {
         __new_finish = uninitialized_copy(begin(), __position, __new_start);
         __new_finish = uninitialized_fill_n(__new_finish, __n, __x);
         __new_finish
           = uninitialized_copy(__position, end(), __new_finish);
       }
-      __STL_UNWIND((_Destroy(__new_start,__new_finish), 
-                    _M_deallocate(__new_start.base(),__len)));
+      catch(...)
+       {
+         _Destroy(__new_start,__new_finish); 
+         _M_deallocate(__new_start.base(),__len);
+         __throw_exception_again;
+       }
       _Destroy(_M_start, _M_finish);
       _M_deallocate(_M_start, _M_end_of_storage - _M_start);
       _M_start = __new_start.base();
@@ -761,15 +777,19 @@ vector<_Tp, _Alloc>::_M_range_insert(iterator __position,
       const size_type __len = __old_size + max(__old_size, __n);
       iterator __new_start(_M_allocate(__len));
       iterator __new_finish(__new_start);
-      __STL_TRY {
+      try {
         __new_finish = uninitialized_copy(iterator(_M_start), 
                                          __position, __new_start);
         __new_finish = uninitialized_copy(__first, __last, __new_finish);
         __new_finish
           = uninitialized_copy(__position, iterator(_M_finish), __new_finish);
       }
-      __STL_UNWIND((_Destroy(__new_start,__new_finish), 
-                    _M_deallocate(__new_start.base(),__len)));
+      catch(...)
+       {
+         _Destroy(__new_start,__new_finish);
+         _M_deallocate(__new_start.base(), __len);
+         __throw_exception_again;
+       }
       _Destroy(_M_start, _M_finish);
       _M_deallocate(_M_start, _M_end_of_storage - _M_start);
       _M_start = __new_start.base();
index 0604c033c8a46597385bdde70c127411b055f5ad..e36fedfada5f27f58e92c3c29ed1a94858ad15ed 100644 (file)
 
 #include <bits/std_cstdio.h>     
 #include <bits/std_iostream.h>
-
-#ifdef __STL_USE_EXCEPTIONS
-# include <bits/std_stdexcept.h>
-#endif
+# include <bits/functexcept.h>
 
 namespace std
 {
@@ -98,7 +95,7 @@ void _Rope_iterator_base<_CharT,_Alloc>::_S_setbuf(
            }
            break;
        default:
-           __stl_assert(0);
+         break;
     }
 }
 
@@ -115,7 +112,6 @@ void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache
     size_t __pos = __x._M_current_pos;
     unsigned char __dirns = 0; // Bit vector marking right turns in the path
 
-    __stl_assert(__pos <= __x._M_root->_M_size);
     if (__pos >= __x._M_root->_M_size) {
        __x._M_buf_ptr = 0;
        return;
@@ -133,7 +129,6 @@ void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache
     }
     for(;;) {
        ++__curr_depth;
-       __stl_assert(__curr_depth <= _RopeRep::_S_max_rope_depth);
        __path[__curr_depth] = __curr_rope;
        switch(__curr_rope->_M_tag) {
          case _RopeRep::_S_leaf:
@@ -189,13 +184,11 @@ void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache_for_incr
     unsigned char __dirns = __x._M_path_directions;
     _Rope_RopeConcatenation<_CharT,_Alloc>* __c;
 
-    __stl_assert(__x._M_current_pos <= __x._M_root->_M_size);
     if (__x._M_current_pos - __node_start_pos < __len) {
        /* More stuff in this leaf, we just didn't cache it. */
        _S_setbuf(__x);
        return;
     }
-    __stl_assert(__node_start_pos + __len == __x._M_current_pos);
     //  node_start_pos is starting position of last_node.
     while (--__current_index >= 0) {
        if (!(__dirns & 1) /* Path turned left */) 
@@ -408,12 +401,16 @@ rope<_CharT,_Alloc>::_S_leaf_concat_char_iter
     uninitialized_copy_n(__r->_M_data, __old_len, __new_data);
     uninitialized_copy_n(__iter, __len, __new_data + __old_len);
     _S_cond_store_eos(__new_data[__old_len + __len]);
-    __STL_TRY {
+    try {
        __result = _S_new_RopeLeaf(__new_data, __old_len + __len,
                                   __r->get_allocator());
     }
-    __STL_UNWIND(_RopeRep::__STL_FREE_STRING(__new_data, __old_len + __len,
-                                            __r->get_allocator()));
+    catch(...)
+      {
+       _RopeRep::__STL_FREE_STRING(__new_data, __old_len + __len,
+                                   __r->get_allocator());
+       __throw_exception_again;
+      }
     return __result;
 }
 
@@ -424,7 +421,6 @@ rope<_CharT,_Alloc>::_RopeLeaf*
 rope<_CharT,_Alloc>::_S_destr_leaf_concat_char_iter
                (_RopeLeaf* __r, const _CharT* __iter, size_t __len)
 {
-    __stl_assert(__r->_M_ref_count >= 1);
     if (__r->_M_ref_count > 1)
       return _S_leaf_concat_char_iter(__r, __iter, __len);
     size_t __old_len = __r->_M_size;
@@ -434,18 +430,15 @@ rope<_CharT,_Alloc>::_S_destr_leaf_concat_char_iter
        uninitialized_copy_n(__iter, __len, __r->_M_data + __old_len);
        if (_S_is_basic_char_type((_CharT*)0)) {
            _S_cond_store_eos(__r->_M_data[__old_len + __len]);
-           __stl_assert(__r->_M_c_string == __r->_M_data);
        } else if (__r->_M_c_string != __r->_M_data && 0 != __r->_M_c_string) {
            __r->_M_free_c_string();
            __r->_M_c_string = 0;
        }
        __r->_M_size = __old_len + __len;
-       __stl_assert(__r->_M_ref_count == 1);
        __r->_M_ref_count = 2;
        return __r;
     } else {
        _RopeLeaf* __result = _S_leaf_concat_char_iter(__r, __iter, __len);
-       __stl_assert(__result->_M_ref_count == 1);
        return __result;
     }
 }
@@ -458,34 +451,33 @@ template <class _CharT, class _Alloc>
 rope<_CharT,_Alloc>::_RopeRep*
 rope<_CharT,_Alloc>::_S_tree_concat (_RopeRep* __left, _RopeRep* __right)
 {
-    _RopeConcatenation* __result =
-      _S_new_RopeConcatenation(__left, __right, __left->get_allocator());
-    size_t __depth = __result->_M_depth;
+  _RopeConcatenation* __result = _S_new_RopeConcatenation(__left, __right, 
+                                                     __left->get_allocator());
+  size_t __depth = __result->_M_depth;
     
-      __stl_assert(__left->get_allocator() == __right->get_allocator());
-    if (__depth > 20 && (__result->_M_size < 1000 ||
-                        __depth > _RopeRep::_S_max_rope_depth)) {
-        _RopeRep* __balanced;
+  if (__depth > 20 && (__result->_M_size < 1000 ||
+                      __depth > _RopeRep::_S_max_rope_depth)) 
+    {
+      _RopeRep* __balanced;
       
-       __STL_TRY {
-          __balanced = _S_balance(__result);
-#          ifndef __GC
-            if (__result != __balanced) {
-               __stl_assert(1 == __result->_M_ref_count
-                            && 1 == __balanced->_M_ref_count);
-            }
-#          endif
-          __result->_M_unref_nonnil();
+      try 
+       {
+         __balanced = _S_balance(__result);
+         __result->_M_unref_nonnil();
         }
-       __STL_UNWIND((_C_deallocate(__result,1)));
-               // In case of exception, we need to deallocate
-               // otherwise dangling result node.  But caller
-               // still owns its children.  Thus unref is
-               // inappropriate.
-       return __balanced;
-    } else {
-       return __result;
-    }
+      catch(...)
+       { 
+         _C_deallocate(__result,1);
+         __throw_exception_again;
+       }
+      // In case of exception, we need to deallocate
+      // otherwise dangling result node.  But caller
+      // still owns its children.  Thus unref is
+      // inappropriate.
+      return __balanced;
+    } 
+  else 
+    return __result;
 }
 
 template <class _CharT, class _Alloc>
@@ -503,9 +495,6 @@ rope<_CharT,_Alloc>::_RopeRep* rope<_CharT,_Alloc>::_S_concat_char_iter
     if (_RopeRep::_S_leaf == __r->_M_tag && 
           __r->_M_size + __slen <= _S_copy_max) {
        __result = _S_leaf_concat_char_iter((_RopeLeaf*)__r, __s, __slen);
-#       ifndef __GC
-         __stl_assert(1 == __result->_M_ref_count);
-#       endif
        return __result;
     }
     if (_RopeRep::_S_concat == __r->_M_tag
@@ -517,26 +506,30 @@ rope<_CharT,_Alloc>::_RopeRep* rope<_CharT,_Alloc>::_S_concat_char_iter
          _RopeRep* __nright = 
            _S_leaf_concat_char_iter((_RopeLeaf*)__right, __s, __slen);
          __left->_M_ref_nonnil();
-         __STL_TRY {
+         try {
            __result = _S_tree_concat(__left, __nright);
           }
-         __STL_UNWIND(_S_unref(__left); _S_unref(__nright));
-#         ifndef __GC
-           __stl_assert(1 == __result->_M_ref_count);
-#         endif
+         catch(...)
+           {
+             _S_unref(__left); 
+             _S_unref(__nright);
+             __throw_exception_again;
+           }
          return __result;
        }
     }
     _RopeRep* __nright =
       __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen, __r->get_allocator());
-    __STL_TRY {
+    try {
       __r->_M_ref_nonnil();
       __result = _S_tree_concat(__r, __nright);
     }
-    __STL_UNWIND(_S_unref(__r); _S_unref(__nright));
-#   ifndef __GC
-      __stl_assert(1 == __result->_M_ref_count);
-#   endif
+    catch(...)
+      {
+       _S_unref(__r); 
+       _S_unref(__nright);
+       __throw_exception_again;
+      }
     return __result;
 }
 
@@ -552,7 +545,6 @@ rope<_CharT,_Alloc>::_S_destr_concat_char_iter(
                                              __r->get_allocator());
     size_t __count = __r->_M_ref_count;
     size_t __orig_size = __r->_M_size;
-    __stl_assert(__count >= 1);
     if (__count > 1) return _S_concat_char_iter(__r, __s, __slen);
     if (0 == __slen) {
        __r->_M_ref_count = 2;      // One more than before
@@ -569,14 +561,10 @@ rope<_CharT,_Alloc>::_S_destr_concat_char_iter(
            && __right->_M_size + __slen <= _S_copy_max) {
          _RopeRep* __new_right = 
            _S_destr_leaf_concat_char_iter(__right, __s, __slen);
-         if (__right == __new_right) {
-             __stl_assert(__new_right->_M_ref_count == 2);
-             __new_right->_M_ref_count = 1;
-         } else {
-             __stl_assert(__new_right->_M_ref_count >= 1);
-             __right->_M_unref_nonnil();
-         }
-         __stl_assert(__r->_M_ref_count == 1);
+         if (__right == __new_right) 
+           __new_right->_M_ref_count = 1;
+         else 
+           __right->_M_unref_nonnil();
          __r->_M_ref_count = 2;    // One more than before.
          ((_RopeConcatenation*)__r)->_M_right = __new_right;
          __r->_M_size = __orig_size + __slen;
@@ -590,11 +578,15 @@ rope<_CharT,_Alloc>::_S_destr_concat_char_iter(
     _RopeRep* __right =
       __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen, __r->get_allocator());
     __r->_M_ref_nonnil();
-    __STL_TRY {
+    try {
       __result = _S_tree_concat(__r, __right);
     }
-    __STL_UNWIND(_S_unref(__r); _S_unref(__right))
-    __stl_assert(1 == __result->_M_ref_count);
+    catch(...)
+      {
+       _S_unref(__r); 
+       _S_unref(__right);
+       __throw_exception_again;
+      }
     return __result;
 }
 #endif /* !__GC */
@@ -629,19 +621,29 @@ rope<_CharT,_Alloc>::_S_concat(_RopeRep* __left, _RopeRep* __right)
                                           ((_RopeLeaf*)__right)->_M_data,
                                           __right->_M_size);
            __leftleft->_M_ref_nonnil();
-           __STL_TRY {
+           try {
              return(_S_tree_concat(__leftleft, __rest));
             }
-           __STL_UNWIND(_S_unref(__leftleft); _S_unref(__rest))
+           catch(...)
+             {
+               _S_unref(__leftleft); 
+               _S_unref(__rest);
+               __throw_exception_again;
+             }
          }
        }
     }
     __left->_M_ref_nonnil();
     __right->_M_ref_nonnil();
-    __STL_TRY {
+    try {
       return(_S_tree_concat(__left, __right));
     }
-    __STL_UNWIND(_S_unref(__left); _S_unref(__right));
+    catch(...)
+      {
+       _S_unref(__left); 
+       _S_unref(__right);
+       __throw_exception_again;
+      }        
 }
 
 template <class _CharT, class _Alloc>
@@ -684,9 +686,6 @@ rope<_CharT,_Alloc>::_S_substring(_RopeRep* __base,
                _Self_destruct_ptr __right_result(
                  _S_substring(__right, 0, __endp1 - __left_len));
                __result = _S_concat(__left_result, __right_result);
-#               ifndef __GC
-                 __stl_assert(1 == __result->_M_ref_count);
-#               endif
                return __result;
            }
        case _RopeRep::_S_leaf:
@@ -738,18 +737,20 @@ rope<_CharT,_Alloc>::_S_substring(_RopeRep* __base,
                if (__result_len > __lazy_threshold) goto lazy;
                __section = (_CharT*)
                        _Data_allocate(_S_rounded_up_size(__result_len));
-               __STL_TRY {
+               try {
                  (*(__f->_M_fn))(__start, __result_len, __section);
                 }
-               __STL_UNWIND(_RopeRep::__STL_FREE_STRING(
-                      __section, __result_len, __base->get_allocator()));
+               catch(...)
+                 {
+                   _RopeRep::__STL_FREE_STRING(
+                      __section, __result_len, __base->get_allocator());
+                   __throw_exception_again;
+                 }
                _S_cond_store_eos(__section[__result_len]);
                return _S_new_RopeLeaf(__section, __result_len,
                                       __base->get_allocator());
            }
     }
-    /*NOTREACHED*/
-    __stl_assert(false);
   lazy:
     {
        // Create substring node.
@@ -862,19 +863,20 @@ bool rope<_CharT, _Alloc>::_S_apply_to_pieces(
                bool __result;
                _CharT* __buffer =
                  (_CharT*)alloc::allocate(__len * sizeof(_CharT));
-               __STL_TRY {
+               try {
                  (*(__f->_M_fn))(__begin, __len, __buffer);
                  __result = __c(__buffer, __len);
                   alloc::deallocate(__buffer, __len * sizeof(_CharT));
                 }
-               __STL_UNWIND((alloc::deallocate(__buffer,
-                                               __len * sizeof(_CharT))))
+               catch(...)
+                 {
+                   alloc::deallocate(__buffer, __len * sizeof(_CharT));
+                   __throw_exception_again;
+                 }
                return __result;
            }
        default:
-           __stl_assert(false);
-           /*NOTREACHED*/
-           return false;
+         return false;
     }
 }
 
@@ -909,7 +911,7 @@ basic_ostream<_CharT, _Traits>& operator<< (basic_ostream<_CharT, _Traits>& __o,
        __pad_len = 0;
     }
     if (!__is_simple) __o.width(__w/__rope_len);
-    __STL_TRY {
+    try {
       if (__is_simple && !__left && __pad_len > 0) {
        _Rope_fill(__o, __pad_len);
       }
@@ -920,7 +922,12 @@ basic_ostream<_CharT, _Traits>& operator<< (basic_ostream<_CharT, _Traits>& __o,
       if (!__is_simple)
         __o.width(__w);
     }
-    __STL_UNWIND(if (!__is_simple) __o.width(__w))
+    catch(...)
+      {
+       if (!__is_simple) 
+         __o.width(__w);
+       __throw_exception_again;
+      }
     return __o;
 }
 
@@ -977,8 +984,6 @@ rope<_CharT,_Alloc>::_S_flatten(_RopeRep* __r, _CharT* __buffer)
                return __buffer + __f->_M_size;
            }
        default:
-           __stl_assert(false);
-           /*NOTREACHED*/
            return 0;
     }
 }
@@ -1081,7 +1086,7 @@ rope<_CharT,_Alloc>::_S_balance(_RopeRep* __r)
 
     for (__i = 0; __i <= _RopeRep::_S_max_rope_depth; ++__i) 
       __forest[__i] = 0;
-    __STL_TRY {
+    try {
       _S_add_to_forest(__r, __forest);
       for (__i = 0; __i <= _RopeRep::_S_max_rope_depth; ++__i) 
         if (0 != __forest[__i]) {
@@ -1090,20 +1095,20 @@ rope<_CharT,_Alloc>::_S_balance(_RopeRep* __r)
 #      endif
          __result = _S_concat(__forest[__i], __result);
        __forest[__i]->_M_unref_nonnil();
-#      if !defined(__GC) && defined(__STL_USE_EXCEPTIONS)
+#      if !defined(__GC) && defined(__EXCEPTIONS)
          __forest[__i] = 0;
 #      endif
       }
     }
-    __STL_UNWIND(for(__i = 0; __i <= _RopeRep::_S_max_rope_depth; __i++)
-                _S_unref(__forest[__i]))
-    if (__result->_M_depth > _RopeRep::_S_max_rope_depth) {
-#     ifdef __STL_USE_EXCEPTIONS
-       __STL_THROW(length_error("rope too long"));
-#     else
-       abort();
-#     endif
-    }
+    catch(...)
+      {
+       for(__i = 0; __i <= _RopeRep::_S_max_rope_depth; __i++)
+         _S_unref(__forest[__i]);
+       __throw_exception_again;
+      }
+
+    if (__result->_M_depth > _RopeRep::_S_max_rope_depth)
+      __throw_length_error("rope too long");
     return(__result);
 }
 
@@ -1116,7 +1121,7 @@ rope<_CharT,_Alloc>::_S_add_to_forest(_RopeRep* __r, _RopeRep** __forest)
        _S_add_leaf_to_forest(__r, __forest);
        return;
     }
-    __stl_assert(__r->_M_tag == _RopeRep::_S_concat);
+
     {
        _RopeConcatenation* __c = (_RopeConcatenation*)__r;
 
@@ -1153,8 +1158,6 @@ rope<_CharT,_Alloc>::_S_add_leaf_to_forest(_RopeRep* __r, _RopeRep** __forest)
     }
     // Too_tiny dead, and no longer included in refcount.
     // Insertee is live and included.
-    __stl_assert(_S_is_almost_balanced(__insertee));
-    __stl_assert(__insertee->_M_depth <= __r->_M_depth + 1);
     for (;; ++__i) {
        if (0 != __forest[__i]) {
 #          ifndef __GC
@@ -1163,10 +1166,7 @@ rope<_CharT,_Alloc>::_S_add_leaf_to_forest(_RopeRep* __r, _RopeRep** __forest)
            __insertee = _S_concat_and_set_balanced(__forest[__i], __insertee);
            __forest[__i]->_M_unref_nonnil();
            __forest[__i] = 0;
-           __stl_assert(_S_is_almost_balanced(__insertee));
        }
-       __stl_assert(_S_min_len[__i] <= __insertee->_M_size);
-       __stl_assert(__forest[__i] == 0);
        if (__i == _RopeRep::_S_max_rope_depth || 
              __insertee->_M_size < _S_min_len[__i+1]) {
            __forest[__i] = __insertee;
@@ -1182,7 +1182,6 @@ rope<_CharT,_Alloc>::_S_fetch(_RopeRep* __r, size_type __i)
 {
     __GC_CONST _CharT* __cstr = __r->_M_c_string;
 
-    __stl_assert(__i < __r->_M_size);
     if (0 != __cstr) return __cstr[__i]; 
     for(;;) {
       switch(__r->_M_tag) {
@@ -1336,13 +1335,9 @@ _Rope_char_ref_proxy<_CharT, _Alloc>::operator= (_CharT __c) {
     _Self_destruct_ptr __result_left(
       _My_rope::_S_destr_concat_char_iter(__left, &__c, 1));
 
-#   ifndef __GC
-      __stl_assert(__left == __result_left || 1 == __result_left->_M_ref_count);
-#   endif
     _RopeRep* __result =
                _My_rope::_S_concat(__result_left, __right);
 #   ifndef __GC
-      __stl_assert(1 <= __result->_M_ref_count);
       _RopeRep::_S_unref(__old);
 #   endif
     _M_root->_M_tree_ptr = __result;
@@ -1388,10 +1383,14 @@ rope<_CharT, _Alloc>::rope(size_t __n, _CharT __c,
        __rest_buffer = _Data_allocate(_S_rounded_up_size(__rest));
        uninitialized_fill_n(__rest_buffer, __rest, __c);
        _S_cond_store_eos(__rest_buffer[__rest]);
-       __STL_TRY {
+       try {
            __remainder = _S_new_RopeLeaf(__rest_buffer, __rest, __a);
         }
-       __STL_UNWIND(_RopeRep::__STL_FREE_STRING(__rest_buffer, __rest, __a))
+       catch(...)
+         {
+           _RopeRep::__STL_FREE_STRING(__rest_buffer, __rest, __a);
+           __throw_exception_again;
+         }
     }
     __remainder_rope._M_tree_ptr = __remainder;
     if (__exponent != 0) {
@@ -1401,19 +1400,19 @@ rope<_CharT, _Alloc>::rope(size_t __n, _CharT __c,
        rope __base_rope;
        uninitialized_fill_n(__base_buffer, __exponentiate_threshold, __c);
        _S_cond_store_eos(__base_buffer[__exponentiate_threshold]);
-       __STL_TRY {
+       try {
           __base_leaf = _S_new_RopeLeaf(__base_buffer,
                                         __exponentiate_threshold, __a);
         }
-       __STL_UNWIND(_RopeRep::__STL_FREE_STRING(__base_buffer, 
-                                                __exponentiate_threshold, __a))
+       catch(...)
+         {
+           _RopeRep::__STL_FREE_STRING(__base_buffer, 
+                                       __exponentiate_threshold, __a);
+           __throw_exception_again;
+         }
        __base_rope._M_tree_ptr = __base_leaf;
        if (1 == __exponent) {
          __result = __base_rope;
-#         ifndef __GC
-           __stl_assert(2 == __result._M_tree_ptr->_M_ref_count);
-               // One each for base_rope and __result
-#         endif
        } else {
          __result = power(__base_rope, __exponent,
                           _Rope_Concat_fn<_CharT,_Alloc>());
@@ -1490,8 +1489,6 @@ _Rope_rotate(_Rope_iterator __first,
   typedef typename _Rope_iterator::value_type _CharT;
   typedef typename _Rope_iterator::_allocator_type _Alloc;
   
-  __stl_assert(__first.container() == __middle.container()
-                           && __middle.container() == __last.container());
   rope<_CharT,_Alloc>& __r(__first.container());
   rope<_CharT,_Alloc> __prefix = __r.substr(0, __first.index());
   rope<_CharT,_Alloc> __suffix = 
index 8dca4bffcd6ebe6c4cbded3ca3740e5ed267662d..cc6b6dfa6d212b1025d0153886e1bf5ba8b6b27d 100644 (file)
@@ -317,21 +317,29 @@ private:
 
   _Node* _M_create_node(const value_type& __x) {
     _Node* __node = this->_M_get_node();
-    __STL_TRY {
+    try {
       _Construct(&__node->_M_data, __x);
       __node->_M_next = 0;
     }
-    __STL_UNWIND(this->_M_put_node(__node));
+    catch(...)
+      {
+       this->_M_put_node(__node);
+       __throw_exception_again;
+      }
     return __node;
   }
   
   _Node* _M_create_node() {
     _Node* __node = this->_M_get_node();
-    __STL_TRY {
+    try {
       _Construct(&__node->_M_data);
       __node->_M_next = 0;
     }
-    __STL_UNWIND(this->_M_put_node(__node));
+    catch(...)
+      {
+       this->_M_put_node(__node);
+       __throw_exception_again;
+      }
     return __node;
   }
 
index c0c8b661a46d14cf00001111e7d46e75a4aa91a0..83e6ad6c1964bd9212efb47cae34a6aec9c2d31a 100644 (file)
@@ -516,11 +516,15 @@ private:
   {
     _Node* __n = _M_get_node();
     __n->_M_next = 0;
-    __STL_TRY {
+    try {
       _Construct(&__n->_M_val, __obj);
       return __n;
     }
-    __STL_UNWIND(_M_put_node(__n));
+    catch(...)
+      {
+       _M_put_node(__n);
+       __throw_exception_again;
+      }
   }
   
   void _M_delete_node(_Node* __n)
@@ -849,7 +853,7 @@ void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>
     if (__n > __old_n) {
       vector<_Node*, _All> __tmp(__n, (_Node*)(0),
                                  _M_buckets.get_allocator());
-      __STL_TRY {
+      try {
         for (size_type __bucket = 0; __bucket < __old_n; ++__bucket) {
           _Node* __first = _M_buckets[__bucket];
           while (__first) {
@@ -862,7 +866,6 @@ void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>
         }
         _M_buckets.swap(__tmp);
       }
-#         ifdef __STL_USE_EXCEPTIONS
       catch(...) {
         for (size_type __bucket = 0; __bucket < __tmp.size(); ++__bucket) {
           while (__tmp[__bucket]) {
@@ -871,9 +874,8 @@ void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>
             __tmp[__bucket] = __next;
           }
         }
-        throw;
+        __throw_exception_again;
       }
-#         endif /* __STL_USE_EXCEPTIONS */
     }
   }
 }
@@ -937,7 +939,7 @@ void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>
   _M_buckets.clear();
   _M_buckets.reserve(__ht._M_buckets.size());
   _M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*) 0);
-  __STL_TRY {
+  try {
     for (size_type __i = 0; __i < __ht._M_buckets.size(); ++__i) {
       const _Node* __cur = __ht._M_buckets[__i];
       if (__cur) {
@@ -954,7 +956,11 @@ void hashtable<_Val,_Key,_HF,_Ex,_Eq,_All>
     }
     _M_num_elements = __ht._M_num_elements;
   }
-  __STL_UNWIND(clear());
+  catch(...)
+    {
+      clear();
+      __throw_exception_again;
+    }
 }
 
 } // namespace std
index d50bb885f1252b654643178edcb25206be69957f..96ec4952d6959506b382c28eec0ab80524090ffb 100644 (file)
@@ -572,7 +572,6 @@ struct _Rope_RopeLeaf : public _Rope_RopeRep<_CharT,_Alloc> {
         : _Rope_RopeRep<_CharT,_Alloc>(_S_leaf, 0, true, __size, __a),
           _M_data(__d)
         {
-        __stl_assert(__size > 0);
         if (_S_is_basic_char_type((_CharT *)0)) {
             // already eos terminated.
             _M_c_string = __d;
@@ -646,7 +645,6 @@ struct _Rope_RopeFunction : public _Rope_RopeRep<_CharT,_Alloc> {
       , _M_delete_when_done(__d)
 #       endif
     {
-        __stl_assert(__size > 0);
 #       ifdef __GC
             if (__d) {
                 GC_REGISTER_FINALIZER(
@@ -685,8 +683,6 @@ struct _Rope_RopeSubstring : public _Rope_RopeFunction<_CharT,_Alloc>,
               {
                 char_producer<_CharT>* __fn =
                         ((_Rope_RopeFunction<_CharT,_Alloc>*)_M_base)->_M_fn;
-                __stl_assert(__start_pos + __req_len <= _M_size);
-                __stl_assert(_M_start + _M_size <= _M_base->_M_size);
                 (*__fn)(__start_pos + _M_start, __req_len, __buffer);
               }
               break;
@@ -699,7 +695,7 @@ struct _Rope_RopeSubstring : public _Rope_RopeFunction<_CharT,_Alloc>,
               }
               break;
             default:
-              __stl_assert(false);
+             break;
         }
     }
     typedef typename _Rope_rep_base<_CharT,_Alloc>::allocator_type
@@ -711,8 +707,6 @@ struct _Rope_RopeSubstring : public _Rope_RopeFunction<_CharT,_Alloc>,
         _M_base(__b),
         _M_start(__s)
     {
-        __stl_assert(__l > 0);
-        __stl_assert(__s + __l <= __b->_M_size);
 #       ifndef __GC
             _M_base->_M_ref_nonnil();
 #       endif
@@ -743,11 +737,11 @@ struct _Rope_RopeSubstring : public _Rope_RopeFunction<_CharT,_Alloc>,
     _Rope_RopeRep<_CharT,_Alloc>* _M_ptr;
     ~_Rope_self_destruct_ptr() 
       { _Rope_RopeRep<_CharT,_Alloc>::_S_unref(_M_ptr); }
-#   ifdef __STL_USE_EXCEPTIONS
+#ifdef __EXCEPTIONS
         _Rope_self_destruct_ptr() : _M_ptr(0) {};
-#   else
+#else
         _Rope_self_destruct_ptr() {};
-#   endif
+#endif
     _Rope_self_destruct_ptr(_Rope_RopeRep<_CharT,_Alloc>* __p) : _M_ptr(__p) {}
     _Rope_RopeRep<_CharT,_Alloc>& operator*() { return *_M_ptr; }
     _Rope_RopeRep<_CharT,_Alloc>* operator->() { return _M_ptr; }
@@ -818,7 +812,6 @@ class _Rope_char_ptr_proxy {
       : _M_pos(__x._M_pos), _M_root(__x._M_root) {}
     _Rope_char_ptr_proxy() {}
     _Rope_char_ptr_proxy(_CharT* __x) : _M_root(0), _M_pos(0) {
-        __stl_assert(0 == __x);
     }
     _Rope_char_ptr_proxy& 
     operator= (const _Rope_char_ptr_proxy& __x) {
@@ -1403,10 +1396,14 @@ class rope : public _Rope_base<_CharT,_Alloc> {
 
             uninitialized_copy_n(__s, __size, __buf);
             _S_cond_store_eos(__buf[__size]);
-            __STL_TRY {
+            try {
               return _S_new_RopeLeaf(__buf, __size, __a);
             }
-            __STL_UNWIND(_RopeRep::__STL_FREE_STRING(__buf, __size, __a))
+            catch(...)
+             {
+               _RopeRep::__STL_FREE_STRING(__buf, __size, __a);
+               __throw_exception_again;
+             }
         }
             
 
@@ -1541,10 +1538,14 @@ class rope : public _Rope_base<_CharT,_Alloc> {
             _CharT* __buf = _Data_allocate(_S_rounded_up_size(1));
 
             _Construct(__buf, __c);
-            __STL_TRY {
+            try {
                 _M_tree_ptr = _S_new_RopeLeaf(__buf, 1, __a);
             }
-            __STL_UNWIND(_RopeRep::__STL_FREE_STRING(__buf, 1, __a))
+            catch(...)
+             {
+               _RopeRep::__STL_FREE_STRING(__buf, 1, __a);
+               __throw_exception_again;
+             }
         }
 
         rope(size_t __n, _CharT __c,
@@ -1576,7 +1577,6 @@ class rope : public _Rope_base<_CharT,_Alloc> {
         rope& operator=(const rope& __x)
         {
             _RopeRep* __old = _M_tree_ptr;
-            __stl_assert(get_allocator() == __x.get_allocator());
             _M_tree_ptr = __x._M_tree_ptr;
             _S_ref(_M_tree_ptr);
             _S_unref(__old);
@@ -1614,12 +1614,16 @@ class rope : public _Rope_base<_CharT,_Alloc> {
             _RopeRep* __old = _M_tree_ptr;
             _RopeRep* __left =
               __STL_ROPE_FROM_UNOWNED_CHAR_PTR(&__x, 1, get_allocator());
-            __STL_TRY {
+            try {
               _M_tree_ptr = _S_concat(__left, _M_tree_ptr);
               _S_unref(__old);
               _S_unref(__left);
             }
-            __STL_UNWIND(_S_unref(__left))
+            catch(...)
+             {
+               _S_unref(__left);
+               __throw_exception_again;
+             }
         }
 
         void pop_front()
@@ -1793,8 +1797,6 @@ class rope : public _Rope_base<_CharT,_Alloc> {
         }
 
         rope& append(const_iterator __s, const_iterator __e) {
-            __stl_assert(__s._M_root == __e._M_root);
-            __stl_assert(get_allocator() == __s._M_root->get_allocator());
             _Self_destruct_ptr __appendee(_S_substring(
               __s._M_root, __s._M_current_pos, __e._M_current_pos));
             _RopeRep* __result = 
@@ -1815,7 +1817,6 @@ class rope : public _Rope_base<_CharT,_Alloc> {
         rope& append() { return append(_CharT()); }  // XXX why?
 
         rope& append(const rope& __y) {
-            __stl_assert(__y.get_allocator() == get_allocator());
             _RopeRep* __result = _S_concat(_M_tree_ptr, __y._M_tree_ptr);
             _S_unref(_M_tree_ptr);
             _M_tree_ptr = __result;
@@ -1828,7 +1829,6 @@ class rope : public _Rope_base<_CharT,_Alloc> {
         }
 
         void swap(rope& __b) {
-            __stl_assert(get_allocator() == __b.get_allocator());
             _RopeRep* __tmp = _M_tree_ptr;
             _M_tree_ptr = __b._M_tree_ptr;
             __b._M_tree_ptr = __tmp;
@@ -1846,7 +1846,6 @@ class rope : public _Rope_base<_CharT,_Alloc> {
               _S_substring(__old, __pos2, __old->_M_size));
             _RopeRep* __result;
 
-            __stl_assert(__old->get_allocator() == __r->get_allocator());
             if (0 == __r) {
                 __result = _S_concat(__left, __right);
             } else {
@@ -1860,7 +1859,6 @@ class rope : public _Rope_base<_CharT,_Alloc> {
         void insert(size_t __p, const rope& __r) {
             _RopeRep* __result = 
               replace(_M_tree_ptr, __p, __p, __r._M_tree_ptr);
-            __stl_assert(get_allocator() == __r.get_allocator());
             _S_unref(_M_tree_ptr);
             _M_tree_ptr = __result;
         }
@@ -2326,7 +2324,6 @@ rope<_CharT,_Alloc>
 operator+ (const rope<_CharT,_Alloc>& __left,
            const rope<_CharT,_Alloc>& __right)
 {
-    __stl_assert(__left.get_allocator() == __right.get_allocator());
     return rope<_CharT,_Alloc>(
       rope<_CharT,_Alloc>::_S_concat(__left._M_tree_ptr, __right._M_tree_ptr));
     // Inlining this should make it possible to keep __left and
index b10a21986e6efb5fd78042a57ba306306d7016f5..118aa913bd3a7dcc0782b10bea678c4addf3cb99 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "typeinfo"
 #include "exception"
-#include <cstddef>
+#include <cstdlib>
 #include "unwind-cxx.h"
 #include "exception_defines.h"
 
@@ -54,3 +54,4 @@ __cxa_bad_typeid ()
   std::abort();
 #endif
 }
+
index 19fb16a6d4dd6de7e26a4a0cc4b2485636cb2873..5c0ec500632566876ef8742eca0ad2a8a41090c6 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <bits/c++config.h>
 #include <cstdlib>
+#include <exception_defines.h>
 #include "unwind-cxx.h"
 
 using namespace __cxxabiv1;
@@ -412,31 +413,33 @@ __cxa_call_unexpected (_Unwind_Exception *exc_obj)
 
   __cxa_exception *xh = __get_exception_header_from_ue (exc_obj);
 
-  try {
-    __unexpected (xh->unexpectedHandler);
-  } catch (...) {
-    // Get the exception thrown from unexpected.
-    // ??? Foreign exceptions can't be stacked this way.
-
-    __cxa_eh_globals *globals = __cxa_get_globals_fast ();
-    __cxa_exception *new_xh = globals->caughtExceptions;
-
-    // We don't quite have enough stuff cached; re-parse the LSDA.
-    lsda_header_info info;
-    parse_lsda_header (0, xh->languageSpecificData, &info);
-    info.ttype_base = (_Unwind_Ptr) xh->catchTemp;
-
-    // If this new exception meets the exception spec, allow it.
-    if (check_exception_spec (&info, new_xh->exceptionType,
-                             xh->handlerSwitchValue))
-      throw;
-
-    // If the exception spec allows std::bad_exception, throw that.
-    const std::type_info &bad_exc = typeid (std::bad_exception);
-    if (check_exception_spec (&info, &bad_exc, xh->handlerSwitchValue))
-      throw std::bad_exception ();
-
-    // Otherwise, die.
-    __terminate(xh->terminateHandler);
-  }
+  try 
+    { __unexpected (xh->unexpectedHandler); } 
+  catch(...) 
+    {
+      // Get the exception thrown from unexpected.
+      // ??? Foreign exceptions can't be stacked this way.
+      
+      __cxa_eh_globals *globals = __cxa_get_globals_fast ();
+      __cxa_exception *new_xh = globals->caughtExceptions;
+      
+      // We don't quite have enough stuff cached; re-parse the LSDA.
+      lsda_header_info info;
+      parse_lsda_header (0, xh->languageSpecificData, &info);
+      info.ttype_base = (_Unwind_Ptr) xh->catchTemp;
+      
+      // If this new exception meets the exception spec, allow it.
+      if (check_exception_spec (&info, new_xh->exceptionType,
+                               xh->handlerSwitchValue))
+       __throw_exception_again;
+      
+      // If the exception spec allows std::bad_exception, throw that.
+#ifdef __EXCEPTIONS  
+      const std::type_info &bad_exc = typeid (std::bad_exception);
+      if (check_exception_spec (&info, &bad_exc, xh->handlerSwitchValue))
+       throw std::bad_exception();
+#endif   
+      // Otherwise, die.
+      __terminate(xh->terminateHandler);
+    }
 }
index 6b52df7f5ad3a4d4fae19404d18e4ce4969a8951..df43e6e45769c95f07203c8d01a3fd649c9d614a 100644 (file)
@@ -28,6 +28,7 @@
 // the GNU General Public License.
 
 #include "new"
+#include <cstdlib>
 #include <exception_defines.h>
 
 using std::new_handler;
index 5bd8ec8a47b35d4ceda632b12746725aa3b10ab2..557fd039432ca9bd8aeb23cabd99acd757f926c6 100644 (file)
@@ -34,7 +34,6 @@
 #include <new>
 #include <exception>
 #include <exception_defines.h>
-
 #include "unwind-cxx.h"
 
 namespace __cxxabiv1
index 8cfaaac7ec962cfbc6b997cbf3f4be188364b0c3..9798e8f2ca0a1accc39d9e693f4c9b4c24e0b350 100644 (file)
@@ -110,43 +110,43 @@ namespace std
   { abort(); }
 
   void
-  __throw_logic_error(const char* __s)
+  __throw_logic_error(const char*)
   { abort(); }
 
   void
-  __throw_domain_error(const char* __s)
+  __throw_domain_error(const char*)
   { abort(); }
 
   void
-  __throw_invalid_argument(const char* __s)
+  __throw_invalid_argument(const char*)
   { abort(); }
 
   void
-  __throw_length_error(const char* __s)
+  __throw_length_error(const char*)
   { abort(); }
 
   void
-  __throw_out_of_range(const char* __s)
+  __throw_out_of_range(const char*)
   { abort(); }
 
   void
-  __throw_runtime_error(const char* __s)
+  __throw_runtime_error(const char*)
   { abort(); }
 
   void
-  __throw_range_error(const char* __s)
+  __throw_range_error(const char*)
   { abort(); }
 
   void
-  __throw_overflow_error(const char* __s)
+  __throw_overflow_error(const char*)
   { abort(); }
 
   void
-  __throw_underflow_error(const char* __s)
+  __throw_underflow_error(const char*)
   { abort(); }
 
   void
-  __throw_ios_failure(const char* __s)
+  __throw_ios_failure(const char*)
   { abort(); }
 #endif //__EXCEPTIONS
 }
index cef2cf99e52e3ac49a1e21ddbb34d020a1a6b682..f9a9726c198ee1a074b0e3dba95fbcb7f0305b27 100644 (file)
 #include <bitset>
 #include <testsuite_hooks.h>
 
-bool test01(void)
+void 
+test01(void)
 {
   bool test = true;
   const size_t n1 = 5;
 
-// the other 22 member functions should be in here too...
-
-
-  // test()
+  // the other 22 member functions should be in here too...
   try {
     std::bitset<n1> five_bits;
     bool unused = five_bits.test(n1);   // should throw
@@ -43,12 +41,7 @@ bool test01(void)
   catch(...) {
     VERIFY( false );
   }
-  
-
-#ifdef DEBUG_ASSERT
-  assert(test);
-#endif
-  return test;
+  VERIFY( test );
 }
 
 int main()