libstdc++/10093: Regression: Setting failbit in exceptions doesn't work
Pétur Runólfsson
peturr02@ru.is
Mon Mar 24 18:21:00 GMT 2003
I wrote:
> I agree, however I also think that exceptions() should be consistent
> with itself, that is, setting exceptions(foobit) should simply mean
> that whenever foobit is set in rdstate(), an exception is thrown.
> In the current implementation (and to some extent, the standard)
> the effect of exceptions(foobit) differs between the various I/O
> functions and depends on the value of foobit.
Just to clarify:
What I think that ios::exceptions() means (and what appears to have
been the intent, judging by some old USENET posts) is that this
should always work:
istream is(...);
is.exceptions(...);
...
try
{
is >> x;
assert((is.exceptions() & is.rdstate()) == 0);
}
catch (...)
{
assert((is.exceptions() & is.rdstate()) != 0);
}
Likewise for ostream and for unformatted I/O functions. Also, the
value of is.rdstate() at the end of this code should not depend on
the value of is.exceptions().
Regards,
Petur
More information about the Libstdc++
mailing list