This is the mail archive of the libstdc++@sources.redhat.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: [patchlet] Re: <sstream> bug?


On 20 Jul 2000 at 18:31 (-0700), Benjamin Kosnik wrote:
| 
| Known issue, should be explictly checking for goodbit, not using the 
| operator bool conversion (which checks for failbit)  ...

I've found a potentially sane solution to this problem.

as reported, DR 195 suggests that sentry::sentry() should set 
eofbit|failbit when/if EOF is hit.

I believe the DRs proposed solution is incorrect for the following
two reasons.

1) setting failbit in the sentry ctor causes the following to break,
     istream_obj >> std::ws;
   since sentry ctor would indiscriminately set failbit whenever it
   hits EOF on the input stream. the definition of std::ws says
   it must set eofbit, when EOF is read, but not failbit if a whitespace
   character was extracted by the input operation.

2) setting eofbit anytime EOF is seen in the sentry ctor causes 
   istream arithmetic extractors to not behave consistently with
   char/string extractors, since only eofbit is set when EOF is
   hit, while the input operation spec says failbit should also
   be set.

I believe our versions of the arithmetic extractors and std::ws 
exhibit compliant behavior. Based on the belief, the only solution 
to this problem that I see is to _never_ let sentry ctor set failbit, 
delegating this to the input operation. eofbit should only be set if 
the first attempted read results in an EOF.

I have a patch for sentry::sentry() to cause this behavior. If 
this solution is sane, I can send it along. It causes no testsuite
failures, while yeilding arithmetic extraction consistent with
char/string extraction.

cheers.
  Brent

-- 
Damon Brent Verner                        o      _     _         _
Cracker Jack? Surprise Certified  _o     /\_   _ \\o  (_)\__/o  (_)
brent@rcfile.org                _< \_   _>(_) (_)/<_    \_| \   _|/' \/
brent@linux1.org               (_)>(_) (_)        (_)   (_)    (_)'  _\o_

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