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]

C++ PATCH: Fix static11.C



This patch fixes the static11.C regression reported on a number of
big-endian platforms.

The problem was that we support two different means of handling static
destruction.  The first, fully conformant with the new ABI spec,
depends on a special run-time library routine not available in most
vendor C libraries.  The second is the old-style .fini section
approach.

Unfortunately, we were doing both at once.  That resulted in twiddling 
two different bits in the same variable, which caused destructors not
to be run.

Tested on mips-sgi-irix6.5, installed on the mainline and on the
branch.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

Mon Apr 30 16:14:10 2001  Mark P Mitchell  <mark@codesourcery.com>

	* decl2.c (start_static_initialization_or_destruction): Correct
	logic to handle the -fno-use-cxa-atexit case.

Index: decl2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl2.c,v
retrieving revision 1.437.2.14
diff -c -p -r1.437.2.14 decl2.c
*** decl2.c	2001/04/29 11:50:55	1.437.2.14
--- decl2.c	2001/04/30 21:20:30
*************** start_static_initialization_or_destructi
*** 3222,3231 ****
  	  my_friendly_assert (initp, 20000629);
  	  guard_cond = get_guard_cond (guard);
  	}
!       /* Under the old ABI, e do initializations only if the GUARD is
! 	 zero, i.e., if we are the first to initialize the variable.
! 	 We do destructions only if the GUARD is one, i.e., if we are
! 	 the last to destroy the variable.  */
        else if (initp)
  	guard_cond 
  	  = cp_build_binary_op (EQ_EXPR,
--- 3222,3234 ----
  	  my_friendly_assert (initp, 20000629);
  	  guard_cond = get_guard_cond (guard);
  	}
!       /* If we don't have __cxa_atexit, then we will be running
! 	 destructors from .fini sections, or their equivalents.  So,
! 	 we need to know how many times we've tried to initialize this
! 	 object.  We do initializations only if the GUARD is zero,
! 	 i.e., if we are the first to initialize the variable.  We do
! 	 destructions only if the GUARD is one, i.e., if we are the
! 	 last to destroy the variable.  */
        else if (initp)
  	guard_cond 
  	  = cp_build_binary_op (EQ_EXPR,
*************** start_static_initialization_or_destructi
*** 3246,3254 ****
  
    finish_if_stmt_cond (cond, guard_if_stmt);
  
!   /* Under the new ABI, we have not already set the GUARD, so we must
!      do so now.  */
!   if (guard && initp)
      finish_expr_stmt (set_guard (guard));
  
    return guard_if_stmt;
--- 3249,3257 ----
  
    finish_if_stmt_cond (cond, guard_if_stmt);
  
!   /* If we're using __cxa_atexit, we have not already set the GUARD,
!      so we must do so now.  */
!   if (guard && initp && flag_use_cxa_atexit)
      finish_expr_stmt (set_guard (guard));
  
    return guard_if_stmt;


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