This is the mail archive of the libstdc++@sourceware.cygnus.com 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]

two small fixes.


first the simple one:
this will silence another annoying -Wall warning

*bits/std_streambuf.h (basic_streambuf()): re-ordered member
initializers to match declaration order

*** org/libstdc++/bits/std_streambuf.h	Sat Jul 24 14:12:05 1999
--- mod/libstdc++/bits/std_streambuf.h	Sat Jul 31 05:24:11 1999
***************
*** 203,209 ****
  
      protected:
        basic_streambuf()
!       : _M_buf_size(0), _M_buf(NULL), _M_buf_unified(false),
  	_M_in_cur(0), _M_in_beg(0), _M_in_end(0), _M_out_cur(0), _M_out_beg(0),
  	_M_out_end(0), _M_mode(ios_base::openmode(0)), 
  	_M_locale_buf(locale()), _M_locale_set(false) 
--- 203,209 ----
  
      protected:
        basic_streambuf()
!       : _M_buf(NULL), _M_buf_size(0), _M_buf_unified(false),
  	_M_in_cur(0), _M_in_beg(0), _M_in_end(0), _M_out_cur(0), _M_out_beg(0),
  	_M_out_end(0), _M_mode(ios_base::openmode(0)), 
  	_M_locale_buf(locale()), _M_locale_set(false) 


This one is real:
compiling e.g. 17_intro/header_fstream.cc 
with recent cvs gcc 2.96 there is a linker error:

./src/.libs/libstdc++.a(misc-inst.o): In function `basic_ios<char, char_traits<char> >::init(basic_streambuf<char, char_traits<char> > *)':
/home/am/gcc/egcs_current/libstdc++/bits/basic_ios.h:253: undefined reference to `ios_base::goodbit'
/home/am/gcc/egcs_current/libstdc++/bits/basic_ios.h:253: undefined reference to `ios_base::badbit'
...

The reason is in bits/ios_base.h

  class ios_base
  {
...
    static const iostate failbit = iostate(_IO_ERR_SEEN);
    static const iostate goodbit = iostate(0);
...
  }

together with uses of the sort (...,ios_base::iostate& __err,...)
in bits/locale_facets.h (and maybe somewhere else)
[this second statement is more a founded guess].

And as the standard says a static const integral member having an in-class initializer
can appear in constant expressions, but must still be defined if 
it is used. And ios_base::iostate& is such a use as internally its address is needed
and the compile needs the indication where to reserve the space.
So we need a

const ios_base::iostate ios_base::goodbit;
const ios_base::iostate ios_base::badbit;

somewhere in namespace std.

It seems that gcc 2.95 does some internal magic to allocate this space,
but if I'm not wrong 2.96 is more correct and it is not a new compiler bug.

If you are sure that there will never be a use in this sense of all
the other static const integral members (boolalpha ... eofbit ... ate ... cur)
then only the definition of goodbit and badbit suffice.

Well, I have defined them all (as they are public, it seems more correct to me).
I chose ios.cc as place where to put it.

*src/ios.cc Add definitions for static constant ios_base members

*** org/libstdc++/src/ios.cc	Sat Jul 24 14:12:09 1999
--- mod/libstdc++/src/ios.cc	Thu Aug  5 13:55:05 1999
***************
*** 270,275 ****
--- 270,312 ----
      // XXX done?
    }
  
+   //Outline definitions for static const ios_base members
+ 		
+   const ios_base::fmtflags ios_base::boolalpha;
+   const ios_base::fmtflags ios_base::dec;
+   const ios_base::fmtflags ios_base::fixed;
+   const ios_base::fmtflags ios_base::hex;
+   const ios_base::fmtflags ios_base::internal;
+   const ios_base::fmtflags ios_base::left;
+   const ios_base::fmtflags ios_base::oct;
+   const ios_base::fmtflags ios_base::right;
+   const ios_base::fmtflags ios_base::scientific;
+   const ios_base::fmtflags ios_base::showbase;
+   const ios_base::fmtflags ios_base::showpoint;
+   const ios_base::fmtflags ios_base::showpos;
+   const ios_base::fmtflags ios_base::skipws;
+   const ios_base::fmtflags ios_base::unitbuf;
+   const ios_base::fmtflags ios_base::uppercase;
+   const ios_base::fmtflags ios_base::adjustfield;
+   const ios_base::fmtflags ios_base::basefield;
+   const ios_base::fmtflags ios_base::floatfield;
+ 
+   const ios_base::iostate ios_base::badbit;
+   const ios_base::iostate ios_base::eofbit;
+   const ios_base::iostate ios_base::failbit;
+   const ios_base::iostate ios_base::goodbit;
+ 
+   const ios_base::openmode ios_base::app;
+   const ios_base::openmode ios_base::ate;
+   const ios_base::openmode ios_base::binary;
+   const ios_base::openmode ios_base::in;
+   const ios_base::openmode ios_base::out;
+   const ios_base::openmode ios_base::trunc;
+ 
+   const ios_base::seekdir ios_base::beg;
+   const ios_base::seekdir ios_base::cur;
+   const ios_base::seekdir ios_base::end;
+ 
  }  // namespace std
  
  
  
Alfred

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