From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19674 invoked by alias); 26 Mar 2003 02:36:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 19660 invoked by uid 71); 26 Mar 2003 02:36:01 -0000 Date: Wed, 26 Mar 2003 02:56:00 -0000 Message-ID: <20030326023601.19659.qmail@sources.redhat.com> To: jlquinn@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Martin Sebor Subject: Re: libstdc++/10093: Regression: Setting failbit in exceptions doesn't work Reply-To: Martin Sebor X-SW-Source: 2003-03/txt/msg01756.txt.bz2 List-Id: The following reply was made to PR libstdc++/10093; it has been noted by GNATS. From: Martin Sebor To: gcc-gnats@gcc.gnu.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