This is the mail archive of the gcc-bugs@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]

gcc bug and a dirty hack for std_bitset.h


hi,
let's look into the standard c++ header file std_bitset.h and the 
specialized _Base_bitset<1>'s _M_do_find_first (the _M_do_find_next 
totaly the same) function's definition (not declaration):
----------------------------
size_t _Base_bitset<1>::_M_do_find_first(size_t __not_found) const
----------------------------
it should have be (according to the standard specification):
----------------------------
template<>
size_t _Base_bitset<1>::_M_do_find_first(size_t __not_found) const
----------------------------
but gcc gives in this case:
----------------------------
/usr/include/g++-v3/bits/std_bitset.h:380: template-id `_M_do_find_first<>' for
`std::_Base_bitset<1>::_M_do_find_first (unsigned int) const' does not match any
 template declaration
/usr/include/g++-v3/bits/std_bitset.h:380: syntax error before `{'
/usr/include/g++-v3/bits/std_bitset.h:385: `_WordT' was not declared in this sco
pe
/usr/include/g++-v3/bits/std_bitset.h:385: parse error before `;'
/usr/include/g++-v3/bits/std_bitset.h:385: syntax error before `++'
/usr/include/g++-v3/bits/std_bitset.h:391: syntax error before `>='
/usr/include/g++-v3/bits/std_bitset.h:399: syntax error before `::'
----------------------------
but in the current case we define non-inline, non-template member function
in header function which of cource gives multiple definition:
----------------------------
libx.a(y.o): In function `std::_Base_bitset<1>::_M_do_find_first(unsigned int)
const':
FlowBookmark.o(.text+0x2b8): multiple definition of `std::_Base_bitset<1>::_M_do
_find_first(unsigned int) const'
----------------------------
so here is my dirty patch (insert an inline before the definition) for 
std_bitset.h (which include the other bitset patch which I send earlier today).
of cource the right solution would fix it in gcc:-)
yours.
 
 -- Levente
 "The only thing worse than not knowing the truth is
  ruining the bliss of ignorance."
--- g++-v3/bits/std_bitset.h.lfarkas	Thu Oct 12 14:16:18 2000
+++ g++-v3/bits/std_bitset.h	Thu Oct 12 16:37:59 2000
@@ -287,7 +287,7 @@
   // check subsequent words
   __i++;
   for ( ; __i < _Nw; __i++ ) {
-    _WordT __thisword = _M_w[__i];
+    __thisword = _M_w[__i];
     if ( __thisword != static_cast<_WordT>(0) ) {
       // find byte within word
       for ( size_t __j = 0; __j < sizeof(_WordT); __j++ ) {
@@ -375,7 +375,7 @@
 //  _Base_bitset.
 //
 
-size_t _Base_bitset<1>::_M_do_find_first(size_t __not_found) const
+inline size_t _Base_bitset<1>::_M_do_find_first(size_t __not_found) const
 {
   _WordT __thisword = _M_w;
 
@@ -394,7 +394,7 @@
   return __not_found;
 }
 
-size_t _Base_bitset<1>::_M_do_find_next(size_t __prev, size_t __not_found ) const
+inline size_t _Base_bitset<1>::_M_do_find_next(size_t __prev, size_t __not_found ) const
 {
   // make bound inclusive
   ++__prev;

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