[patch] Apply DR434 resolution to <debug/bitset>

Jonathan Wakely cow@compsoc.man.ac.uk
Tue May 10 15:39:00 GMT 2005


On Fri, May 06, 2005 at 02:27:47PM +0200, Paolo Carlini wrote:

> Jonathan Wakely wrote:
> 
> >So apart from PR 16021 there's nothing serious.
> >  
> >
> Ah, ok, thanks a lot!
> 
> Then, let's figure out the cleanest solution string/element_access...
> I'm tempted to go with my simple #ifdef but want to give this a little
> more thought...

It seems obvious now I look at it:

      reference
      operator[](size_type __pos)
      {
        _GLIBCXX_DEBUG_PEDASSERT(__pos < size());
        // allow v3 extension when not in pedantic mode:
        _GLIBCXX_DEBUG_ASSERT(__pos <= size());
        _M_leak();
        return _M_data()[__pos];
      }

This does the check twice in pedantic mode, but that's not a problem.

BUT while checking that I noticed a serious problem with pedantic mode,
see attached patch.  This is wrong in 3.4, 4.0 and mainline, and makes
it rather difficult to test the above fix for std::string, since I was
never activating pedantic mode!  :)

2005-05-10  Jonathan Wakely

	* include/debug/debug.h: Fix typo in macro name.

OK for mainline and 4.0 ?  What about 3.4 ?

jon

-- 
"No one pretends that democracy is perfect or all wise.
 It has been said that democracy is the worst form of government,
 except for all the others that have been tried from time to time."
	- Winston Churchill, 1947.
-------------- next part --------------
Index: include/debug/debug.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/debug/debug.h,v
retrieving revision 1.3
diff -u -p -r1.3 debug.h
--- include/debug/debug.h	31 Jan 2005 16:21:46 -0000	1.3
+++ include/debug/debug.h	10 May 2005 15:33:36 -0000
@@ -226,7 +226,7 @@ _GLIBCXX_DEBUG_VERIFY(::std::__is_heap(_
 #ifdef _GLIBCXX_DEBUG
 #  define _GLIBCXX_DEBUG_ASSERT(_Condition) assert(_Condition)
 
-#  ifdef _GLIBXX_DEBUG_PEDANTIC
+#  ifdef _GLIBCXX_DEBUG_PEDANTIC
 #    define _GLIBCXX_DEBUG_PEDASSERT(_Condition) assert(_Condition)
 #  else
 #    define _GLIBCXX_DEBUG_PEDASSERT(_Condition)


More information about the Libstdc++ mailing list