public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/9024: Input fails after call to basic_filebuf<>::pubsetbuf(0, 0)
@ 2002-12-20 11:16 paolo
  0 siblings, 0 replies; 8+ messages in thread
From: paolo @ 2002-12-20 11:16 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, paolo, peturr02

Synopsis: Input fails after call to basic_filebuf<>::pubsetbuf(0, 0)

Responsible-Changed-From-To: paolo->unassigned
Responsible-Changed-By: paolo
Responsible-Changed-When: Fri Dec 20 11:16:24 2002
Responsible-Changed-Why:
    .
State-Changed-From-To: feedback->analyzed
State-Changed-By: paolo
State-Changed-When: Fri Dec 20 11:16:24 2002
State-Changed-Why:
    .

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


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

* Re: libstdc++/9024: Input fails after call to basic_filebuf<>::pubsetbuf(0, 0)
@ 2003-03-03 10:56 Paolo Carlini
  0 siblings, 0 replies; 8+ messages in thread
From: Paolo Carlini @ 2003-03-03 10:56 UTC (permalink / raw)
  To: paolo; +Cc: gcc-prs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1213 bytes --]

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

From: Paolo Carlini <pcarlini@unitus.it>
To: =?ISO-8859-1?Q?P=E9tur_Run=F3lfsson?= <peturr02@ru.is>
Cc: gcc-gnats@gcc.gnu.org,  gcc-bugs@gcc.gnu.org,  paolo@gcc.gnu.org, 
 gcc-prs@gcc.gnu.org, bkoz <bkoz@redhat.com>
Subject: Re: libstdc++/9024: Input fails after call to basic_filebuf<>::pubsetbuf(0,
 0)
Date: Mon, 03 Mar 2003 11:45:47 +0100

 Pétur Runólfsson wrote:
 
 >>A memo: while working on a fix for libstdc++/9423 (quite easy 
 >>by itself),
 >>finally seems obvious how to fix 9024: in _M_underflow_common add a
 >>separate case for !__testget && !__testinit, which simply calls
 >>_M_file.xsgetn(&__c, 1) and returns __ret = 
 >>traits_type::to_int_type(__c).
 >>    
 >>
 >Does this work when codecvt::encoding() != 1 ?
 >
 One thing at a time Pétur!
 Your problem report was about plain chars, right?
 
 Eventually, _M_underflow_common(wchar_t) will obviously include 
 something along
 these lines (the approach works, by the way), taking into account 
 encoding() to fetch the
 appropriate number of external bytes decoded to get one internal char, 
 together with other
 fixes for 9178 and 9875.
 
 Paolo.
 
 
 


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

* RE: libstdc++/9024: Input fails after call to basic_filebuf<>::pubsetbuf(0, 0)
@ 2003-03-03 10:46 Pétur Runólfsson
  0 siblings, 0 replies; 8+ messages in thread
From: Pétur Runólfsson @ 2003-03-03 10:46 UTC (permalink / raw)
  To: paolo; +Cc: gcc-prs

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

From: =?iso-8859-1?Q?P=E9tur_Run=F3lfsson?= <peturr02@ru.is>
To: "Paolo Carlini" <pcarlini@unitus.it>,
	<gcc-gnats@gcc.gnu.org>,
	<gcc-bugs@gcc.gnu.org>,
	<paolo@gcc.gnu.org>,
	<gcc-prs@gcc.gnu.org>
Cc: "bkoz" <bkoz@redhat.com>
Subject: RE: libstdc++/9024: Input fails after call to basic_filebuf<>::pubsetbuf(0, 0)
Date: Mon, 3 Mar 2003 10:38:22 -0000

 > A memo: while working on a fix for libstdc++/9423 (quite easy=20
 > by itself),
 > finally seems obvious how to fix 9024: in _M_underflow_common add a
 > separate case for !__testget && !__testinit, which simply calls
 > _M_file.xsgetn(&__c, 1) and returns __ret =3D=20
 > traits_type::to_int_type(__c).
 
 Does this work when codecvt::encoding() !=3D 1 ?
 
 Petur


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

* Re: libstdc++/9024: Input fails after call to basic_filebuf<>::pubsetbuf(0, 0)
@ 2003-03-02 21:26 Paolo Carlini
  0 siblings, 0 replies; 8+ messages in thread
From: Paolo Carlini @ 2003-03-02 21:26 UTC (permalink / raw)
  To: paolo; +Cc: gcc-prs

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

From: Paolo Carlini <pcarlini@unitus.it>
To: gcc-gnats@gcc.gnu.org,  peturr02@ru.is,  gcc-bugs@gcc.gnu.org, 
 paolo@gcc.gnu.org,  gcc-prs@gcc.gnu.org
Cc: bkoz <bkoz@redhat.com>
Subject: Re: libstdc++/9024: Input fails after call to basic_filebuf<>::pubsetbuf(0,
 0)
Date: Sun, 02 Mar 2003 22:16:30 +0100

 A memo: while working on a fix for libstdc++/9423 (quite easy by itself),
 finally seems obvious how to fix 9024: in _M_underflow_common add a
 separate case for !__testget && !__testinit, which simply calls
 _M_file.xsgetn(&__c, 1) and returns __ret = traits_type::to_int_type(__c).
 
 Stay tuned!
 
 Paolo.
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9024
 


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

* Re: libstdc++/9024: Input fails after call to basic_filebuf<>::pubsetbuf(0, 0)
@ 2002-12-20 14:34 paolo
  0 siblings, 0 replies; 8+ messages in thread
From: paolo @ 2002-12-20 14:34 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, paolo, peturr02

Synopsis: Input fails after call to basic_filebuf<>::pubsetbuf(0, 0)

Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Fri Dec 20 14:34:48 2002
Responsible-Changed-Why:
    Tentative patch in progress.

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


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

* Re: libstdc++/9024: Input fails after call to basic_filebuf<>::pubsetbuf(0, 0)
@ 2002-12-20 11:26 Paolo Carlini
  0 siblings, 0 replies; 8+ messages in thread
From: Paolo Carlini @ 2002-12-20 11:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

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

From: Paolo Carlini <pcarlini@unitus.it>
To: gcc-gnats@gcc.gnu.org,  gcc-prs@gcc.gnu.org,  peturr02@ru.is, 
 gcc-bugs@gcc.gnu.org,  paolo@gcc.gnu.org
Cc:  
Subject: Re: libstdc++/9024: Input fails after call to basic_filebuf<>::pubsetbuf(0,
 0)
Date: Fri, 20 Dec 2002 20:17:24 +0100

 Sorry, submitter is correct: of course, before _any_ I/O on _that_ stream!
 
 Paolo.
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9024
 


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

* Re: libstdc++/9024: Input fails after call to basic_filebuf<>::pubsetbuf(0, 0)
@ 2002-12-20 11:07 paolo
  0 siblings, 0 replies; 8+ messages in thread
From: paolo @ 2002-12-20 11:07 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, paolo, peturr02

Synopsis: Input fails after call to basic_filebuf<>::pubsetbuf(0, 0)

Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Fri Dec 20 11:07:04 2002
Responsible-Changed-Why:
    Analyzed.
State-Changed-From-To: open->feedback
State-Changed-By: paolo
State-Changed-When: Fri Dec 20 11:07:04 2002
State-Changed-Why:
    The current behaviour seems standard conforming: according
    to 27.8.1.4,10, _only_ if setbuf(0,0) is called before _any_
    I/O has occurred the stream becomes unbuffered, otherwise
    the results are implementation defined.
    Indeed, if the _second_ pubsetbuf call (that at line 52)
    is removed from the testcase, basic_ifstream is usable
    without problems as expected.

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


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

* libstdc++/9024: Input fails after call to basic_filebuf<>::pubsetbuf(0, 0)
@ 2002-12-20  6:46 peturr02
  0 siblings, 0 replies; 8+ messages in thread
From: peturr02 @ 2002-12-20  6:46 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9024
>Category:       libstdc++
>Synopsis:       Input fails after call to basic_filebuf<>::pubsetbuf(0, 0)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 20 06:46:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     peturr02@ru.is
>Release:        gcc-3.2.1
>Organization:
>Environment:
Redhat Linux 8.0 on i686; glibc-2.2.93
>Description:
It is not possible to use a basic_ifstream s for input if s.rdbuf()->pubsetbuf(0, 0) has been called.

The call pubsetbuf(0, 0) is described in:

Bjarne Stroustrup, The C++ Programing Language, 3rd edition,
Section 21.6.4, page 647:
"By default, setbuf(0, 0) means "unbuffered""

Nicolai M. Josuttis, The C++ Standard Library, page 664:
"...the use of [pubsetbuf] is only portable if it is called
before the first I/O operation is performed and it is called as pubsetbuf(0, 0)..."
>How-To-Repeat:
See attachment.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="setbuf.cc"
Content-Disposition: inline; filename="setbuf.cc"

//////////////////////////////////////////////////////////////////////
// setbuf.cc
//
// Test program for basic_filebuf<>::pubsetbuf
//
// Bjarne Stroustrup, The C++ Programing Language, 3rd edition,
// Section 21.6.4, page 647:
// "By default, setbuf(0, 0) means "unbuffered""
//
// Nicolai M. Josuttis, The C++ Standard Library, page 664:
// "...the use of [pubsetbuf] is only portable if it is called
// before the first I/O operation is performed and it is called as
// pubsetbuf(0, 0)..."
//////////////////////////////////////////////////////////////////////

#include <fstream>
#include <string>
#include <iterator>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

int main()
{
  string const str1 = "abcdefghijklmnopqrstuvwxyz";
  string str2;
  string str3;

  char name[] = "pubsetbuftestXXXXXX";
  mktemp(name);

  {
    ofstream stream1;
    if (!stream1.rdbuf()->pubsetbuf(0, 0))
      assert(false);
    stream1.open(name);
    copy(str1.begin(), str1.end(), ostreambuf_iterator<char>(stream1));
  }

  {
    ifstream stream2;
    stream2.open(name);
    copy(istreambuf_iterator<char>(stream2), istreambuf_iterator<char>(),
	 back_inserter(str2));
  }

  {
    ifstream stream3;
    if (!stream3.rdbuf()->pubsetbuf(0, 0))
      assert(false);
    stream3.open(name);
    copy(istreambuf_iterator<char>(stream3),
	 istreambuf_iterator<char>(),
	 back_inserter(str3));
  }

  remove(name);
  
  cout << "str1 = " << str1 << endl;
  cout << "str2 = " << str2 << endl;
  cout << "str3 = " << str3 << endl;

  assert(str1 == str2);
  assert(str1 == str3);
  
  return 0;
}


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

end of thread, other threads:[~2003-03-03 10:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-20 11:16 libstdc++/9024: Input fails after call to basic_filebuf<>::pubsetbuf(0, 0) paolo
  -- strict thread matches above, loose matches on Subject: below --
2003-03-03 10:56 Paolo Carlini
2003-03-03 10:46 Pétur Runólfsson
2003-03-02 21:26 Paolo Carlini
2002-12-20 14:34 paolo
2002-12-20 11:26 Paolo Carlini
2002-12-20 11:07 paolo
2002-12-20  6:46 peturr02

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).