This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[v3] libsupc++/vec.cc update


Fixes for a bug in the ABI.  Nobody has responded to my mail to the ABI
list, so I'm just checking it in, to both trunk and branch.

Alex, I've included the patch to the ABI document as well.

2001-03-20  Jason Merrill  <jason@redhat.com>

	* libsupc++/vec.cc (__cxa_vec_cleanup): New fn.
	(__cxa_vec_ctor, __cxa_vec_cctor, __cxa_vec_dtor): Call it.
	* libsupc++/cxxabi.h: Declare it.

*** ./libsupc++/cxxabi.h.~1~	Tue Mar 20 13:31:18 2001
--- ./libsupc++/cxxabi.h	Tue Mar 20 13:31:36 2001
*************** void __cxa_vec_dtor (void *__array_addre
*** 473,478 ****
--- 473,485 ----
                       __SIZE_TYPE__ __element_size,
                       void (*__destructor) (void *));
  
+ /* destruct array */
+ extern "C"
+ void __cxa_vec_cleanup (void *__array_address,
+ 			__SIZE_TYPE__ __element_count,
+ 			__SIZE_TYPE__ __element_size,
+ 			void (*__destructor) (void *));
+ 
  /* destruct and release array */
  extern "C"
  void __cxa_vec_delete (void *__array_address,
*** ./libsupc++/vec.cc.~1~	Tue Mar 20 13:31:18 2001
--- ./libsupc++/vec.cc	Tue Mar 20 13:31:36 2001
*************** namespace __cxxabiv1
*** 150,156 ****
        {
  	{
  	  uncatch_exception ue;
! 	  __cxa_vec_dtor(array_address, ix, element_size, destructor);
  	}
  	__throw_exception_again;
        }
--- 150,156 ----
        {
  	{
  	  uncatch_exception ue;
! 	  __cxa_vec_cleanup(array_address, ix, element_size, destructor);
  	}
  	__throw_exception_again;
        }
*************** namespace __cxxabiv1
*** 180,186 ****
        {
  	{
  	  uncatch_exception ue;
! 	  __cxa_vec_dtor (dest_array, ix, element_size, destructor);
  	}
  	__throw_exception_again;
        }
--- 180,186 ----
        {
  	{
  	  uncatch_exception ue;
! 	  __cxa_vec_cleanup(dest_array, ix, element_size, destructor);
  	}
  	__throw_exception_again;
        }
*************** namespace __cxxabiv1
*** 197,206 ****
        {
  	char *ptr = static_cast<char *>(array_address);
  	std::size_t ix = element_count;
! 	bool unwinding = std::uncaught_exception();
!       
  	ptr += element_count * element_size;
!       
  	try
  	  {
  	    while (ix--)
--- 197,205 ----
        {
  	char *ptr = static_cast<char *>(array_address);
  	std::size_t ix = element_count;
! 
  	ptr += element_count * element_size;
! 
  	try
  	  {
  	    while (ix--)
*************** namespace __cxxabiv1
*** 211,225 ****
  	  }
  	catch (...)
  	  {
- 	    if (unwinding)
- 	      // [except.ctor]/3 If a destructor called during stack unwinding
- 	      // exits with an exception, terminate is called.
- 	      std::terminate ();
  	    {
  	      uncatch_exception ue;
! 	      __cxa_vec_dtor(array_address, ix, element_size, destructor);
  	    }
  	    __throw_exception_again;
  	  }
        }
    }
--- 210,251 ----
  	  }
  	catch (...)
  	  {
  	    {
  	      uncatch_exception ue;
! 	      __cxa_vec_cleanup(array_address, ix, element_size, destructor);
  	    }
  	    __throw_exception_again;
+ 	  }
+       }
+   }
+ 
+   // Destruct array as a result of throwing an exception.
+   // [except.ctor]/3 If a destructor called during stack unwinding
+   // exits with an exception, terminate is called.
+   extern "C" void
+   __cxa_vec_cleanup(void *array_address,
+ 		    std::size_t element_count,
+ 		    std::size_t element_size,
+ 		    void (*destructor) (void *))
+   {
+     if (destructor)
+       {
+ 	char *ptr = static_cast <char *> (array_address);
+ 	std::size_t ix = element_count;
+ 
+ 	ptr += element_count * element_size;
+ 
+ 	try
+ 	  {
+ 	    while (ix--)
+ 	      {
+ 		ptr -= element_size;
+ 		destructor(ptr);
+ 	      }
+ 	  }
+ 	catch (...)
+ 	  {
+ 	    std::terminate();
  	  }
        }
    }
*** abi.html.~1~	Sat Nov 18 00:13:27 2000
--- abi.html	Tue Mar 20 15:45:53 2001
*************** in which case this routine does nothing.
*** 3295,3300 ****
--- 3295,3317 ----
  </dd>
  
  <dt><code><pre>
+ extern "C" void __cxa_vec_cleanup (
+ 	    void *array_address,
+ 	    size_t element_count,
+ 	    size_t element_size,
+ 	    void (*destructor) ( void *this ) );
+ </pre></code></dt>
+ <dd>
+ Given the (data) address of an array,
+ the number of elements,
+ and the size of its elements,
+ call the given destructor on each element.
+ If the destructor throws an exception, call terminate.
+ The destructor pointer may be NULL,
+ in which case this routine does nothing.
+ </dd>
+ 
+ <dt><code><pre>
  extern "C" void __cxa_vec_delete (
  	    void *array_address,
  	    size_t element_size,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]