From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8722 invoked by alias); 20 Dec 2002 14:46:05 -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 8700 invoked by uid 71); 20 Dec 2002 14:46:03 -0000 Resent-Date: 20 Dec 2002 14:46:03 -0000 Resent-Message-ID: <20021220144603.8699.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, peturr02@ru.is Received: (qmail 7326 invoked by uid 61); 20 Dec 2002 14:38:00 -0000 Message-Id: <20021220143759.7319.qmail@sources.redhat.com> Date: Fri, 20 Dec 2002 06:46:00 -0000 From: peturr02@ru.is Reply-To: peturr02@ru.is To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: libstdc++/9024: Input fails after call to basic_filebuf<>::pubsetbuf(0, 0) X-SW-Source: 2002-12/txt/msg01091.txt.bz2 List-Id: >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 #include #include #include #include #include #include #include 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(stream1)); } { ifstream stream2; stream2.open(name); copy(istreambuf_iterator(stream2), istreambuf_iterator(), back_inserter(str2)); } { ifstream stream3; if (!stream3.rdbuf()->pubsetbuf(0, 0)) assert(false); stream3.open(name); copy(istreambuf_iterator(stream3), istreambuf_iterator(), 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; }