libstdc++/stl/bitset problems in 19981130 snapshot

Jeff Sparkes jsparkes@internetivity.com
Wed Dec 2 14:18:00 GMT 1998


There appears to be a problem with nested classes accessing members of the
outer class that shows up in the STL bitset class.

I'm using the 19981130 snapshot on linux-2.0.36 with only the --prefix
option
to configure.

The following patch works around the problem by making some of the members
of bitset
public, which is almost certainly the wrong thing to do.  I'm also including
the test file which exhibits the problems.

(This patch was pasted in, so it's probably got the white space messed up)
Index: bitset
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/libstdc++/stl/bitset,v
retrieving revision 1.2
diff -u -r1.2 bitset
--- bitset      1998/11/27 12:10:39     1.2
+++ bitset      1998/12/02 21:19:19
@@ -542,6 +542,7 @@
   using _Base::_S_whichbyte;
   using _Base::_S_whichbit;
   using _Base::_S_maskbit;
+public:
   using _Base::_M_getword;
   using _Base::_M_hiword;
   using _Base::_M_do_and;

Here is the test program bitset.cc, which is just a cut-down version of how
I'm using bitsets in my code.

#include <cstdio>
#include <stl_algobase.h>       // shouldn't be needed
#include "bitset"

main(int argc, char *argv)
{
        bitset<128> b;
        for (int i=0; i<30; i++) {
                b <<= 3;
                b |= 4;
        }
        for (int i=127; i>=0 ; i--) {
                if (b[i])
                        printf("%d\n", i);
        }
}

Here are the errors that I get with the bitset header that came with the
snapshot:

/usr/local/egcs/bin/g++ bitset.cc
bitset: In method `class bitset<128,long unsigned int> & bitset<128,long
unsigned int>::operator <<=(unsigned int)':
bitset.cc:9:   instantiated from here
bitset:191: `void _Base_bitset<4,long unsigned
int>::_M_do_left_shift(unsigned int)' is from private base class
bitset:655: within this context
bitset: In method `void bitset<128,long unsigned int>::_M_do_sanitize()':
bitset:656:   instantiated from `bitset<128,long unsigned int>::operator
<<=(unsigned int)'
bitset.cc:9:   instantiated from here
bitset:94: `long unsigned int & _Base_bitset<4,long unsigned
int>::_M_hiword()' is from private base class
bitset:566: within this context
bitset: In method `class bitset<128,long unsigned int> & bitset<128,long
unsigned int>::operator |=(const class bitset<128,long unsigned int> &)':
bitset.cc:10:   instantiated from here
bitset:103: `void _Base_bitset<4,long unsigned int>::_M_do_or(const struct
_Base_bitset<4,long unsigned int> &)' is from private base class
bitset:645: within this context
bitset: In method `bitset<128,long unsigned int>::reference::reference(class
bitset<128,long unsigned int> &, unsigned int)':
bitset:752:   instantiated from `bitset<128,long unsigned int>::operator
[](unsigned int)'
bitset.cc:13:   instantiated from here
bitset:91: `long unsigned int & _Base_bitset<4,long unsigned
int>::_M_getword(unsigned int)' is from private base class
bitset:582: within this context




More information about the Gcc-bugs mailing list