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]

Re: basic_streambuf bug


Hi,

--- Nathan Myers <ncm@cantrip.org> wrote:

>  		  int_type __c = this->uflow();  
>  		  if ( __c == traits_type::eof())
>  		    break;
> 
> 	      	  *__s++ = traits_type::to_char_type(__c);
>  		  ++__retval;

This is still broken: You cannot assume that 'operator==()' is the
right way to compare objects of 'int_type'. Likewise, you are supposed
to assign objects with 'traits_type::assign()':

            int_type __c = this->uflow(); // fine: copy ctor is there
            if (traits_type::eq_int_type(__c, traits_type::eof()))
              break;

            traits_type::assign(*__s++, traits_type::to_char_type(c));
            ++__retval;

Strict use of character traits is relatively hard because it is rather
tempting to use a short cut. I haven't created test cases identifying
these problems but I'm sure that I got it wrong in some places with my
implementation, too.

Regards,
  dk


=====
<mailto:dietmar_kuehl@yahoo.com>
<http://www.dietmar-kuehl.de/>

__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/

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