This is the mail archive of the
libstdc++@sources.redhat.com
mailing list for the libstdc++ project.
Re: [patchlet] Re: <sstream> bug?
- To: stdc++ <libstdc++ at sourceware dot cygnus dot com>
- Subject: Re: [patchlet] Re: <sstream> bug?
- From: brent verner <brent at rcfile dot org>
- Date: Mon, 24 Jul 2000 13:26:06 -0400
- References: <Pine.SOL.3.91.1000720182915.15138A@cse.cygnus.com>
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_