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]
Other format: [Raw text]

[v3] revert strstream patch


This patch reverts the change made to strstream to plug a memory
leak. It's causing too much collateral damage, especially regressions
from gcc-3.0.x, and on a deprecated part of code I really have no
interest in fixing.

Thus, reversion. 

Also abi.txt updates from yesterday.

Also, making mainline work with -fno-exceptions again.

tested x86/linux
gcc

2002-08-02  Benjamin Kosnik  <bkoz@redhat.com>

	Revert PR libstdc++/6594
	* src/strstream.cc (strstreambuf): Revert.
	(strstreambuf::overflow): Same.
	(strstreambuf::~strstreambuf): Same.	
	* testsuite/backward/strstream_members.cc (test02): Add.
	
	* docs/html/abi.txt: Update. Spell check.

	* testsuite/19_diagnostics/stdexceptions.cc (test04): Add bool test.

	* testsuite/Makefile.am (INCLUDES): Add LIBSUPCXX_INCLUDES.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/testsuite_hooks.h: Use __throw_exception_again,
	include functexcept.h so that -fno-exceptions will build.

Index: docs/html/abi.txt
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/docs/html/abi.txt,v
retrieving revision 1.4
diff -c -p -r1.4 abi.txt
*** docs/html/abi.txt	31 Jul 2002 19:34:07 -0000	1.4
--- docs/html/abi.txt	2 Aug 2002 15:56:43 -0000
*************** I. What is an ABI? What's covered? What'
*** 30,37 ****
    switch between the gcc-3.0.x ABI, gcc-3.1.x ABI, and the gcc-3.2.x
    ABI during compilation. Other C++ compilers do allow this, and some
    g++ command line options may change the ABI (-fno-exceptions, see
!   the complete list), but there is no version switch. Sorry. The GNU
!   Project recommends that
  
  - How can this complexity be managed? What does C++ versioning mean?
    Because library and compiler changes often make binaries compiled
--- 30,39 ----
    switch between the gcc-3.0.x ABI, gcc-3.1.x ABI, and the gcc-3.2.x
    ABI during compilation. Other C++ compilers do allow this, and some
    g++ command line options may change the ABI (-fno-exceptions, see
!   the complete list), but there is no version switch. Sorry. 
! 
!   To use a specific C++ABI, one must use the corresponding GNU C++
!   toolchain. 
  
  - How can this complexity be managed? What does C++ versioning mean?
    Because library and compiler changes often make binaries compiled
*************** I. What is an ABI? What's covered? What'
*** 41,67 ****
    easier.
  
    The following techniques are used:
    - Release versioning on the libgcc_s.so binary.
  
    - Release versioning on the libstdc++.so binary.
  
    - Symbol versioning on the libgcc_s.so binary.
    
    - Symbol versioning on the libstdc++.so binary.
  
    - Incremental bumping of a compiler pre-defined macro,
!     __GXX_ABI_VERSION. This macro will be automatically defined
!     whenever g++ is used (the curious can test this by invoking g++
!     with the '-v' flag. 
      
      This macro is defined in the file "lang-specs.h" in the gcc/cp directory.
!     
      It is versioned as follows:
      gcc-3.0.x: 100
!     gcc-3.1.x: 100
!     gcc-3.2.x: 101
  
-     Ask the compiler people why this makes sense, or what this macro means.
  
    - Incremental bumping of a library pre-defined macro,
      __GLIBCPP__. This macro is defined as the date the library was
--- 43,119 ----
    easier.
  
    The following techniques are used:
+ 
    - Release versioning on the libgcc_s.so binary.
  
+     It is versioned as follows:
+     gcc-3.0.0: libgcc_s.so.1
+     gcc-3.0.1: libgcc_s.so.1
+     gcc-3.0.2: libgcc_s.so.1
+     gcc-3.0.3: libgcc_s.so.1
+     gcc-3.0.4: libgcc_s.so.1
+     gcc-3.1.0: libgcc_s.so.1
+     gcc-3.1.1: libgcc_s.so.1
+     gcc-3.2.0: libgcc_s.so.1
+ 
+ 
    - Release versioning on the libstdc++.so binary.
  
+     It is versioned as follows:
+     gcc-3.0.0: libstdc++.so.3.0.0
+     gcc-3.0.1: libstdc++.so.3.0.1
+     gcc-3.0.2: libstdc++.so.3.0.2
+     gcc-3.0.3: libstdc++.so.3.0.2 (Error, should be libstdc++.so.3.0.3)
+     gcc-3.0.4: libstdc++.so.3.0.4
+     gcc-3.1.0: libstdc++.so.4.0.0
+     gcc-3.1.1: libstdc++.so.4.0.1
+     gcc-3.2.0: libstdc++.so.5.0.0
+ 
+ 
    - Symbol versioning on the libgcc_s.so binary.
    
+     file: gcc/libgcc-std.ver
+ 
+     It is versioned as follows:
+     gcc-3.0.0: GCC_3.0
+     gcc-3.0.1: GCC_3.0
+     gcc-3.0.2: GCC_3.0
+     gcc-3.0.3: GCC_3.0
+     gcc-3.0.4: GCC_3.0
+     gcc-3.1.0: GCC_3.0
+     gcc-3.1.1: GCC_3.0
+     gcc-3.2.0: GCC_3.0
+ 
+ 
    - Symbol versioning on the libstdc++.so binary.
+   
+     It is versioned as follows:
+     gcc-3.0.0: (Error, unversioned)
+     gcc-3.0.1: (Error, unversioned)
+     gcc-3.0.2: (Error, unversioned)
+     gcc-3.0.3: (Error, unversioned)
+     gcc-3.0.4: (Error, unversioned)
+     gcc-3.1.0: GLIBCPP_3.1, CXXABI_1
+     gcc-3.1.1: GLIBCPP_3.1, CXXABI_1
+     gcc-3.2.0: GLIBCPP_3.2, CXXABI_1.2
+     
+     file: libstdc++-v3/config/linker-map.gnu
+   
  
    - Incremental bumping of a compiler pre-defined macro,
!     __GXX_ABI_VERSION. This macro is defined as the version of the
!     compiler v3 ABI, with g++ 3.0.x being version 100. This macro will
!     be automatically defined whenever g++ is used (the curious can
!     test this by invoking g++ with the '-v' flag.)
      
      This macro is defined in the file "lang-specs.h" in the gcc/cp directory.
!     Later versions define it in "c-common.c" in the gcc directory.
! 
      It is versioned as follows:
      gcc-3.0.x: 100
!     gcc-3.1.x: 100 (Error, should be 101)
!     gcc-3.2.x: 102
  
  
    - Incremental bumping of a library pre-defined macro,
      __GLIBCPP__. This macro is defined as the date the library was
*************** I. What is an ABI? What's covered? What'
*** 81,86 ****
--- 133,139 ----
      gcc-3.1.1: 20020725
      gcc-3.2.0: (20020731)
  
+ 
    - Incremental bumping of a library pre-defined macro,
      _GLIBCPP_VERSION. This macro is defined as the released version of
      the library, as a string literal. This is only implemented in
*************** I. What is an ABI? What's covered? What'
*** 93,112 ****
  
      It is versioned as follows:
      gcc-3.0.0: "3.0.0"
!     gcc-3.0.1: "3.0.0"
!     gcc-3.0.2: "3.0.0"
!     gcc-3.0.3: "3.0.0"
!     gcc-3.0.4: "3.0.0"
      gcc-3.1.0: "3.1.0"
      gcc-3.1.1: "3.1.1"
      gcc-3.2.0: ("3.2.0")
  
    - Matching each specific C++ compiler release to a specific set of
      C++ include files. This is only implemented in gcc-3.1.1 releases
      and higher.
  
      All C++ includes are installed in include/c++, then nest in a
!     directory heirarchy corresponding to the C++ compiler's released
      version. This version corresponds to the variable "gcc_version" in
      "libstdc++-v3/acinclude.m4," and more details can be found in that
      file's macro GLIBCPP_CONFIGURE.
--- 146,166 ----
  
      It is versioned as follows:
      gcc-3.0.0: "3.0.0"
!     gcc-3.0.1: "3.0.0" (Error, should be "3.0.1")
!     gcc-3.0.2: "3.0.0" (Error, should be "3.0.2")
!     gcc-3.0.3: "3.0.0" (Error, should be "3.0.3")
!     gcc-3.0.4: "3.0.0" (Error, should be "3.0.4")
      gcc-3.1.0: "3.1.0"
      gcc-3.1.1: "3.1.1"
      gcc-3.2.0: ("3.2.0")
  
+ 
    - Matching each specific C++ compiler release to a specific set of
      C++ include files. This is only implemented in gcc-3.1.1 releases
      and higher.
  
      All C++ includes are installed in include/c++, then nest in a
!     directory hierarchy corresponding to the C++ compiler's released
      version. This version corresponds to the variable "gcc_version" in
      "libstdc++-v3/acinclude.m4," and more details can be found in that
      file's macro GLIBCPP_CONFIGURE.
*************** I. What is an ABI? What's covered? What'
*** 155,161 ****
    When the GNU C++ library is being built with symbol versioning on,
    you should see the following at configure time for libstdc++-v3:
  
! checking versioning on shared library symbols... gnu
  
    If you don't see this line in the configure output, or if this line
    appears but the last word is 'no', then you are out of luck.
--- 209,215 ----
    When the GNU C++ library is being built with symbol versioning on,
    you should see the following at configure time for libstdc++-v3:
  
!   checking versioning on shared library symbols... gnu
  
    If you don't see this line in the configure output, or if this line
    appears but the last word is 'no', then you are out of luck.
*************** increase, say from "libstdc++.so.3.0.4" 
*** 192,198 ****
  
  - (anything) changing mangling on an exported symbol
  
! - (anything) adding or deleting an exported symbol
  
  The following will cause the library revision version number to
  increase, say from "libstdc++.so.5.0.0" to "libstdc++.so.5.0.1".
--- 246,254 ----
  
  - (anything) changing mangling on an exported symbol
  
! - (anything) deleting an exported symbol
! 
! Note: adding an exported symbol, if it's in a new linker map name, is ok.
  
  The following will cause the library revision version number to
  increase, say from "libstdc++.so.5.0.0" to "libstdc++.so.5.0.1".
*************** compute offsets for each structure and t
*** 251,256 ****
--- 307,317 ----
  saving to another datafile. Then, compute this for new binaries, and
  look for differences.
  
+ An example of a way to compute the list of names exported by the
+ shared libstdc++ binary is:
+ 
+ nm --extern-only --portability libstdc++.so.5.0.0 | awk '{ print $1 $2}'
+ 
  The thought is to choose one or both of these approaches, and to use a
  Makefile hook, perhaps 'make check-abi', to add this capability to the
  libstdc++ testsuite.
*************** V. Issues not directly addressed, and po
*** 270,281 ****
   
    - directory-level versioning
  
! - wrapping C++ API's n "C" to use the C ABI.
  
  
  V. References
  
! ABIcheck, a vauge idea of checking ABI compatibility
  http://abicheck.sourceforge.net/
  
  C++ ABI reference
--- 331,342 ----
   
    - directory-level versioning
  
! - wrapping C++ API's in "C" to use the C ABI.
  
  
  V. References
  
! ABIcheck, a vague idea of checking ABI compatibility
  http://abicheck.sourceforge.net/
  
  C++ ABI reference
Index: src/strstream.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/strstream.cc,v
retrieving revision 1.12
diff -c -p -r1.12 strstream.cc
*** src/strstream.cc	25 Jul 2002 00:04:37 -0000	1.12
--- src/strstream.cc	2 Aug 2002 15:56:44 -0000
*************** namespace std
*** 60,71 ****
    : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(true), 
      _M_frozen(false), _M_constant(false)
    {
!     _M_buf_size = _M_buf_size_opt = max(initial_capacity, streamsize(16));
!     _M_buf = _M_alloc(_M_buf_size);
!     if (_M_buf) 
        {
! 	setp(_M_buf, _M_buf + _M_buf_size);
! 	setg(_M_buf, _M_buf, _M_buf);
        }
    }
  
--- 60,72 ----
    : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(true), 
      _M_frozen(false), _M_constant(false)
    {
!     streamsize n = max(initial_capacity, streamsize(16));
!     
!     char* buf = _M_alloc(n);
!     if (buf) 
        {
! 	setp(buf, buf + n);
! 	setg(buf, buf, buf);
        }
    }
  
*************** namespace std
*** 73,84 ****
    : _Base(), _M_alloc_fun(alloc_f), _M_free_fun(free_f), _M_dynamic(true), 
      _M_frozen(false), _M_constant(false)
    {
!     _M_buf_size = _M_buf_size_opt = 16;
!     _M_buf = _M_alloc(_M_buf_size);
!     if (_M_buf) 
        {
! 	setp(_M_buf, _M_buf + _M_buf_size);
! 	setg(_M_buf, _M_buf, _M_buf);
        }
    }
  
--- 74,86 ----
    : _Base(), _M_alloc_fun(alloc_f), _M_free_fun(free_f), _M_dynamic(true), 
      _M_frozen(false), _M_constant(false)
    {
!     streamsize n = 16;
! 
!     char* buf = _M_alloc(n);
!     if (buf) 
        {
! 	setp(buf, buf + n);
! 	setg(buf, buf, buf);
        }
    }
  
*************** namespace std
*** 116,129 ****
    strstreambuf::~strstreambuf()
    {
      if (_M_dynamic && !_M_frozen)
!       {
! 	char* p = this->eback();
! 	_M_free(p);
! 	if (p == _M_buf)
! 	  _M_buf = 0;
!       }
!     if (_M_buf)
!       _M_free(_M_buf);
    }
  
    void 
--- 118,124 ----
    strstreambuf::~strstreambuf()
    {
      if (_M_dynamic && !_M_frozen)
!       _M_free(eback());
    }
  
    void 
*************** namespace std
*** 169,176 ****
  		old_get_offset = gptr() - eback();
  	      }
  	    
- 	    _M_buf = buf;
- 	    _M_buf_size = _M_buf_size_opt = new_size;
  	    setp(buf, buf + new_size);
  	    pbump(old_size);
  
--- 164,169 ----
Index: testsuite/Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/Makefile.am,v
retrieving revision 1.7
diff -c -p -r1.7 Makefile.am
*** testsuite/Makefile.am	18 Jun 2002 19:07:11 -0000	1.7
--- testsuite/Makefile.am	2 Aug 2002 15:56:44 -0000
*************** RUNTEST = `if [ -f @glibcpp_srcdir@/../d
*** 36,44 ****
  AM_RUNTESTFLAGS =
  RUNTESTFLAGS =
  
! CXX = @glibcpp_CXX@ @GLIBCPP_INCLUDES@
  # Use common includes from acinclude.m4/GLIBCPP_EXPORT_INCLUDES
! INCLUDES = @TOPLEVEL_INCLUDES@
  
  noinst_LIBRARIES = libv3test.a
  
--- 36,46 ----
  AM_RUNTESTFLAGS =
  RUNTESTFLAGS =
  
! CXX = @glibcpp_CXX@ 
  # Use common includes from acinclude.m4/GLIBCPP_EXPORT_INCLUDES
! INCLUDES = \
! 	-nostdinc++ \
! 	@GLIBCPP_INCLUDES@ @LIBSUPCXX_INCLUDES@ @TOPLEVEL_INCLUDES@ 
  
  noinst_LIBRARIES = libv3test.a
  
Index: testsuite/testsuite_hooks.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/testsuite_hooks.h,v
retrieving revision 1.9
diff -c -p -r1.9 testsuite_hooks.h
*** testsuite/testsuite_hooks.h	31 Jul 2002 02:47:34 -0000	1.9
--- testsuite/testsuite_hooks.h	2 Aug 2002 15:56:44 -0000
***************
*** 58,63 ****
--- 58,64 ----
  #define _GLIBCPP_TESTSUITE_HOOKS_H
  
  #include <bits/c++config.h>
+ #include <bits/functexcept.h>
  #include <cstddef>
  
  #ifdef DEBUG_ASSERT
*************** class gnu_copy_tracker
*** 113,119 ****
      : itsId(rhs.id()), willThrow(rhs.willThrow)
      {
        ++itsCopyCount;
!       if (willThrow) throw "copy tracker exception";
      }
  
      gnu_copy_tracker& operator=(const gnu_copy_tracker& rhs)
--- 114,121 ----
      : itsId(rhs.id()), willThrow(rhs.willThrow)
      {
        ++itsCopyCount;
!       if (willThrow) 
! 	__throw_exception_again "copy tracker exception";
      }
  
      gnu_copy_tracker& operator=(const gnu_copy_tracker& rhs)
Index: testsuite/19_diagnostics/stdexceptions.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/19_diagnostics/stdexceptions.cc,v
retrieving revision 1.7
diff -c -p -r1.7 stdexceptions.cc
*** testsuite/19_diagnostics/stdexceptions.cc	17 Apr 2002 06:20:20 -0000	1.7
--- testsuite/19_diagnostics/stdexceptions.cc	2 Aug 2002 15:56:44 -0000
*************** public:
*** 58,64 ****
  void test03()
  {
    bool test = true;
- 
    try
      { throw fuzzy_logic(); }
    catch(const fuzzy_logic& obj)
--- 58,63 ----
*************** void allocate_on_stack(void) 
*** 79,84 ****
--- 78,84 ----
  }
  void test04()
  {
+   bool test = true;
    const std::string s("CA ISO emergency once again:immediate power down");
    const char* strlit1 = "wish I lived in Palo Alto";
    const char* strlit2 = "...or Santa Barbara";
Index: testsuite/backward/strstream_members.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/backward/strstream_members.cc,v
retrieving revision 1.2
diff -c -p -r1.2 strstream_members.cc
*** testsuite/backward/strstream_members.cc	25 Jul 2002 00:04:37 -0000	1.2
--- testsuite/backward/strstream_members.cc	2 Aug 2002 15:56:44 -0000
*************** int test01()
*** 29,40 ****
     for (unsigned i=0 ; i!= 1000 ; ++i)
        s << i << std::endl;
     s << std::ends;
- 
     return 0;
  }
  
  int main()
  {
    test01();
    return 0;
  }
--- 29,49 ----
     for (unsigned i=0 ; i!= 1000 ; ++i)
        s << i << std::endl;
     s << std::ends;
     return 0;
  }
  
+ 
+ int test02()
+ {
+   std::ostrstream buf;
+   buf << std::ends;
+   char *s = buf.str ();
+   delete [] s;
+ }
+ 
  int main()
  {
    test01();
+   test02();
    return 0;
  }


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