public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/4545: basic_ostream op<< should set badbit, not failbit
@ 2001-11-04  4:16 bkoz
  0 siblings, 0 replies; 5+ messages in thread
From: bkoz @ 2001-11-04  4:16 UTC (permalink / raw)
  To: bkoz; +Cc: gcc-prs

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

From: bkoz@gcc.gnu.org
To: bkoz@gcc.gnu.org, brendan@zen.org, gcc-bugs@gcc.gnu.org,
  gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org
Cc:  
Subject: Re: libstdc++/4545: basic_ostream op<< should set badbit, not failbit
Date: 15 Nov 2001 20:43:48 -0000

 Synopsis: basic_ostream op<< should set badbit, not failbit
 
 State-Changed-From-To: feedback->closed
 State-Changed-By: bkoz
 State-Changed-When: Thu Nov 15 12:43:47 2001
 State-Changed-Why:
     Fixed.
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=4545&database=gcc


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: libstdc++/4545: basic_ostream op<< should set badbit, not failbit
@ 2001-11-04  3:49 bkoz
  0 siblings, 0 replies; 5+ messages in thread
From: bkoz @ 2001-11-04  3:49 UTC (permalink / raw)
  To: bkoz, brendan, gcc-bugs, gcc-gnats, gcc-prs

Synopsis: basic_ostream op<< should set badbit, not failbit

State-Changed-From-To: feedback->closed
State-Changed-By: bkoz
State-Changed-When: Thu Nov 15 12:43:47 2001
State-Changed-Why:
    Fixed.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=4545&database=gcc


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: libstdc++/4545: basic_ostream op<< should set badbit, not failbit
@ 2001-10-25 21:36 bkoz
  0 siblings, 0 replies; 5+ messages in thread
From: bkoz @ 2001-10-25 21:36 UTC (permalink / raw)
  To: bkoz, brendan, gcc-bugs, gcc-prs, nobody

Synopsis: basic_ostream op<< should set badbit, not failbit

Responsible-Changed-From-To: unassigned->bkoz
Responsible-Changed-By: bkoz
Responsible-Changed-When: Thu Oct 25 21:36:43 2001
Responsible-Changed-Why:
    Mine.
State-Changed-From-To: open->feedback
State-Changed-By: bkoz
State-Changed-When: Thu Oct 25 21:36:43 2001
State-Changed-Why:
    Brendan, thanks for  pointing this out.
    
    I think that badbit is set when the streambuf is null, and failbit is set when no characters were copied. I believe this is consistent with a careful read of the standard:
    
    1: If sb is null calls setstate(badbit)
    2: If the function inserts no characters, it calls setstate(failbit)
    
    
    Anyway. I believe the function should look like this:
    
      template<typename _CharT, typename _Traits>
        basic_ostream<_CharT, _Traits>& 
        basic_ostream<_CharT, _Traits>::operator<<(__streambuf_type* __sbin)
        {
          sentry __cerb(*this);
          if (__cerb)
    	{
    	  try
    	    {
    	      streamsize __xtrct = 0;
    	      if (__sbin)
    		{
    		  __streambuf_type* __sbout = this->rdbuf();
    		  __xtrct = __copy_streambufs(*this, __sbin, __sbout);
    		}
    	      else
    		this->setstate(ios_base::badbit);
    	      if (!__xtrct)
    		this->setstate(ios_base::failbit);
    	    }
    	  catch(exception& __fail)
    	    {
    	      // 27.6.2.5.1 Common requirements.
    	      // Turn this on without causing an ios::failure to be thrown.
    	      this->setstate(ios_base::badbit);
    	      if ((this->exceptions() & ios_base::badbit) != 0)
    		__throw_exception_again;
    	    }
    	}
          return *this;
        }

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=4545&database=gcc


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: libstdc++/4545 basic_ostream op<< should set badbit, not failbit
@ 2001-10-14 12:36 Craig Rodrigues
  0 siblings, 0 replies; 5+ messages in thread
From: Craig Rodrigues @ 2001-10-14 12:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

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

From: Craig Rodrigues <rodrigc@mediaone.net>
To: gcc-patches@gcc.gnu.org
Cc: libstdc++@gcc.gnu.org, gcc-gnats@gcc.gnu.org, brendan@zen.org,
   rodrigc@gcc.gnu.org
Subject: Re: libstdc++/4545 basic_ostream op<< should set badbit, not failbit
Date: Sun, 14 Oct 2001 15:29:12 -0400

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=4545&database=gcc
 
 Hi,
 
 Following patch addresses PR 4545 on mainline.
 
 "I was mistaken in one piece that I submitted in PR libstdc++/4536.
 
  Rather, according to $27.6.2.5.3(6) the operator
  basic_ostream::operator<<(streambuf*) should tset badbit, not 
  failbit, if __sbin or __xtrct is set to 0."
 
 
 2001-08-02  Brendan Kehoe  <brendan@zen.org>
 
 	* include/bits/ostream.tcc (basic_ostream::op<<(streambuf*)): If
 	__sbin or __xtrct are 0, set badbit, not failbit, per
 	$27.6.2.5.3(6).
 
 *** bits/ostream.tcc.~1~	Wed Jul 18 19:19:42 2001
 --- bits/ostream.tcc	Thu Oct 11 14:59:02 2001
 *************** namespace std 
 *** 347,351 ****
   	__xtrct = __copy_streambufs(*this, __sbin, __sbout);
         if (!__sbin || !__xtrct)
 ! 	this->setstate(ios_base::failbit);
         return *this;
       }
 --- 347,351 ----
   	__xtrct = __copy_streambufs(*this, __sbin, __sbout);
         if (!__sbin || !__xtrct)
 ! 	this->setstate(ios_base::badbit);
         return *this;
       }
 -- 
 Craig Rodrigues        
 http://www.gis.net/~craigr    
 rodrigc@mediaone.net          


^ permalink raw reply	[flat|nested] 5+ messages in thread

* libstdc++/4545: basic_ostream op<< should set badbit, not failbit
@ 2001-10-11  8:26 brendan
  0 siblings, 0 replies; 5+ messages in thread
From: brendan @ 2001-10-11  8:26 UTC (permalink / raw)
  To: gcc-gnats

>Number:         4545
>Category:       libstdc++
>Synopsis:       basic_ostream op<< should set badbit, not failbit
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 11 08:26:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Brendan Kehoe
>Release:        CVS tree
>Organization:
>Environment:

>Description:
I was mistaken in one piece that I submitted in PR libstdc++/4536.

Rather, according to $27.6.2.5.3(6) the operator
  basic_ostream::operator<<(streambuf*)
should tset badbit, not failbit, if __sbin or __xtrct is set to 0.
>How-To-Repeat:

>Fix:
In attached patch, do setstate of ios_base::badbit instead of ios_base::failbit.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="diffs-ostream-2.txt"
Content-Disposition: inline; filename="diffs-ostream-2.txt"

2001-08-02  Brendan Kehoe  <brendan@zen.org>

	* include/bits/ostream.tcc (basic_ostream::op<<(streambuf*)): If
	__sbin or __xtrct are 0, set badbit, not failbit, per
	$27.6.2.5.3(6).

*** bits/ostream.tcc.~1~	Wed Jul 18 19:19:42 2001
--- bits/ostream.tcc	Thu Oct 11 14:59:02 2001
*************** namespace std 
*** 347,351 ****
  	__xtrct = __copy_streambufs(*this, __sbin, __sbout);
        if (!__sbin || !__xtrct)
! 	this->setstate(ios_base::failbit);
        return *this;
      }
--- 347,351 ----
  	__xtrct = __copy_streambufs(*this, __sbin, __sbout);
        if (!__sbin || !__xtrct)
! 	this->setstate(ios_base::badbit);
        return *this;
      }


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-11-15 20:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-04  4:16 libstdc++/4545: basic_ostream op<< should set badbit, not failbit bkoz
  -- strict thread matches above, loose matches on Subject: below --
2001-11-04  3:49 bkoz
2001-10-25 21:36 bkoz
2001-10-14 12:36 libstdc++/4545 " Craig Rodrigues
2001-10-11  8:26 libstdc++/4545: " brendan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).