This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC 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'twork


The following reply was made to PR libstdc++/10093; it has been noted by GNATS.

From: Martin Sebor <sebor at roguewave dot com>
To: gcc-gnats at gcc dot gnu dot org
Cc:  
Subject: Re: libstdc++/10093: Regression: Setting failbit in exceptions doesn't
 work
Date: Tue, 25 Mar 2003 19:29:23 -0700

 Pétur Runólfsson wrote:
  >
 ...
 > Do you mean that "these called functions" in p4 only refers to
 > rdbuf()->sbumpc() and rdbuf()->sgetc() and not setstate()?
 
 Yes, that's how I read it.
 
 > 
 > The part "as if the called function had returned a failure
 > indication" implies that setstate is not included (after all, it
 > doesn't return failure indications), but the part "If badbit is
 > on in exceptions(), [...], otherwise it does not throw anything"
 > implies that s >> x will only throw if
 > (s.exceptions() & ios::badbit) != 0, so setstate should be
 > included (but this contradicts the resolution to DR 64).
 
 I'm not sure I follow you here. Are you concerned that the text
 contradicts itself in that if badbit is not set in exceptions
 but failbit is, calling setstate (failbit) is not allowed to
 throw failure? I don't think that is the intent of the text.
 
 > 
 ...
 >> >  IMO, stream members should consistently catch all
 >> >  exceptions from any functions they may call.
 >>I buy this :-)
 > 
 > 
 > 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.
 
 I agree.
 
 > 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.
 
 I'm not too familiar with the libstdc++ implementation so I can't
 speak for it but I can't think of any place in the standard that
 mandates or allows this behavior. Do you have an example?
 
 > 
 ...
 > [1] Actually, the resolution talks about exceptions thrown "while
 > extracting characters from sb" which seems rather silly as the
 > function extracts characters from rdbuf() and inserts them into
 > sb.
 
 That looks like a typo in the resolution. I would expect the
 function to behave as if the text read:
 
      If the function inserts no characters, it calls setstate
      (failbit), which may throw ios_base::failure (27.4.4.3).
      If the function caught an exception thrown while inserting
      characters into *sb then if failbit is on in exceptions()
      (27.4.4.3), failbit is set in *this without throwing
      ios_base::failure and the caught exception is rethrown;
      otherwise the function calls setstate(failbit), which may
      throw ios_base::failure (27.4.4.3).
 
 Martin
 


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