This is the mail archive of the libstdc++@gcc.gnu.org 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]
Other format: [Raw text]

RE: libstdc++/10093: Regression: Setting failbit in exceptions doesn't work


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


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