This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
Re: std_sstream.h - patch
- To: "Lib3 (E-mail)" <libstdc++@sourceware.cygnus.com>
- Subject: Re: std_sstream.h - patch
- From: "Edwards, Phil" <pedwards@ball.com>
- Date: Wed, 26 May 1999 11:53:29 -0600
Ryszard Kabatek wrote:
+ BTW. The basic_streambuf<>::setbuf in bits/std_streambuf.h
+ does not return any value if 'if (false)' occurs.
Yeah, I started looking through the Standard after -Wall reminded me of
this. The various buffering code is, for the most part, a straight
English-to-C++ translation of the Standard. Perhaps this particular
function followed the English a little too closely.
The relevant block is:
# 27.5.2.4.2 Buffer management and positioning
#
# basic_streambuf* setbuf( char_type* s, streamsize n);
#
# 1 Effects: Performs an operation that is defined separately for
# each class derived from basic_streambuf in this clause.
#
# 2 Default behavior: If gptr() is nonnull and gptr()!= egptr()
# then do nothing. Returns this.
And the code is essentially
if ( (gptr() is non-null) && (gptr() != egptr()) )
return this;
That is, "return this" somehow got connected to the previous sentence.
I think it's supposed to be "derived class are going to do the work
(clause 1), and that work is probably going to be this default (clause
2), but since this is an abstraction base class, just return a useful
pointer that derived classes can use if they forward the calls."
How about just commenting out the test?
Phil
(If you reply to the list, please don't cc another copy to me. Thanks.)
Index: bits/std_streambuf.h
===================================================================
RCS file: /cvs/libstdc++/libstdc++/bits/std_streambuf.h,v
retrieving revision 1.41
diff -c -r1.41 std_streambuf.h
*** std_streambuf.h 1999/05/21 10:33:26 1.41
--- std_streambuf.h 1999/05/26 17:52:36
***************
*** 242,248 ****
virtual basic_streambuf<char_type,_Traits>*
setbuf(char_type*, streamsize)
{
! if (this->gptr() && this->gptr() != this->egptr())
return this;
}
--- 242,248 ----
virtual basic_streambuf<char_type,_Traits>*
setbuf(char_type*, streamsize)
{
! //if (this->gptr() && this->gptr() != this->egptr())
return this;
}