[PATCH] Cleanup in istream.tcc
Martin Sebor
sebor@roguewave.com
Wed Sep 24 18:10:00 GMT 2003
Pétur Runólfsson wrote:
> Martin Sebor wrote:
>
>>>The call to setstate is redundant since sentry::operator bool() only
>>>returns false if sentry::sentry() has already set failbit.
>>
>>Not necessarily. Failbit (or any other bit) may have been set prior
>>to the call to the ctor, in which case the sentry might do nothing
>>and the input function would then call setstate(failbit).
>
>
> In *this* implementation, sentry::sentry() always calls
> setstate(failbit) if !good(), so this patch will not change the
> visible behaviour of any conforming program. This behaviour makes
> sense to me, since otherwise every input function would have to call
> setstate(failbit) if sentry::operator bool() returns false.
>
> This implementation is conforming since the description of
> sentry::sentry states that it "may" set failbit.
I don't read it that way (as you can tell from issue 419).
27.6.1.1.2, p2 starts out by saying:
"If is.good() is true, prepares for ... input..."
^^^^^^^^
The complete sentence from p5 you quoted above says:
"During preparation, the ctor may call setstate(failbit)..."
^^^^^^^^^^^^^^^^^^
So if is.good() is not true, the ctor never begins to prepare the
stream for input and so it cannot do anything during the preparation.
But given issue 419, I guess you could say your implementation
is one step ahead of the game since it already implements the
proposed resolution. But since the issue has not even been
discussed yet, let alone accepted, doing so doesn't make it
conforming, maybe just more useful ;-)
Martin
More information about the Libstdc++
mailing list