This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

Re: [v3] libstdc++/9582


On Wed, Feb 19, 2003 at 12:54:26PM +0100, Paolo Carlini wrote:
> Phil Edwards wrote:
> >On Tue, Feb 18, 2003 at 09:35:27PM +0100, Paolo Carlini wrote:
> >
> >>>Should __debug_alloc<> (which contains the same ODR violation) be
> >>>documented and changed to unconditionally abort() when a size mismatch
> >>>is detected?  This way we can remove the <cassert> inclusion entirely.
> >>>
> >>I agree completely! Do you want me to prepare a patch?
> >>
> >So do I, and yes please, respectively.  We might even consider printing
> >out some diagnostics before aborting -- it's debug_alloc, after all, we
> >don't care if it's slow or brings in extra code.  But that's probably a
> >project for another day.
> >
> Phil, are you willing to work on it? I'm _so_ busy working on those nasty
> stringbuf issues and removing completely the last <cassert> while improving
> the diagnostics for the debug alloc seems really a nice improvement!

Here's the patch to remove the last asserts from stl_alloc.h on trunk.
A similar patch is going in for 3.3, which also has a deallocate memfn there.
I'm just going an abort() for now; will come up with diagnostics later.


2003-02-19  Phil Edwards  <pme at gcc dot gnu dot org>

	PR libstdc++/9582
	* include/bits/stl_alloc.h:  Remove all traces of assert().


Index: include/bits/stl_alloc.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_alloc.h,v
retrieving revision 1.30
diff -u -3 -p -r1.30 stl_alloc.h
--- include/bits/stl_alloc.h	18 Feb 2003 10:54:37 -0000	1.30
+++ include/bits/stl_alloc.h	20 Feb 2003 00:10:04 -0000
@@ -81,7 +81,6 @@
 #include <cstddef>
 #include <cstdlib>
 #include <cstring>
-#include <cassert>
 #include <bits/functexcept.h>   // For __throw_bad_alloc
 #include <bits/stl_threads.h>
 
@@ -217,10 +216,7 @@ namespace std
   /**
    *  @if maint
    *  An adaptor for an underlying allocator (_Alloc) to check the size
-   *  arguments for debugging.  Errors are reported using assert; these
-   *  checks can be disabled via NDEBUG, but the space penalty is still
-   *  paid, therefore it is far better to just use the underlying allocator
-   *  by itelf when no checking is desired.
+   *  arguments for debugging.
    *
    *  "There is some evidence that this can confuse Purify." - SGI comment
    *
@@ -249,7 +245,8 @@ namespace std
       deallocate(void* __p, size_t __n)
       {
         char* __real_p = (char*)__p - (int) _S_extra;
-        assert(*(size_t*)__real_p == __n);
+        if (*(size_t*)__real_p != __n)
+          abort();
         _Alloc::deallocate(__real_p, __n + (int) _S_extra);
       }
     };


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