From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29332 invoked by alias); 5 Jul 2002 00:39:54 -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 29305 invoked by uid 61); 5 Jul 2002 00:39:54 -0000 Date: Thu, 04 Jul 2002 17:39:00 -0000 Message-ID: <20020705003954.29304.qmail@sources.redhat.com> To: bkoz@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, tony.oliver@mci.co.uk From: bkoz@gcc.gnu.org Reply-To: bkoz@gcc.gnu.org, bkoz@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, tony.oliver@mci.co.uk, gcc-gnats@gcc.gnu.org Subject: Re: libstdc++/6746: ifstream::readsome() always returns zero X-SW-Source: 2002-07/txt/msg00181.txt.bz2 List-Id: Synopsis: ifstream::readsome() always returns zero State-Changed-From-To: analyzed->open State-Changed-By: bkoz State-Changed-When: Thu Jul 4 17:39:53 2002 State-Changed-Why: It looks like I am not going to be able to fix this before I leave. I'll resume looking at it after I get back, say July 23 rd ish... In sum, it looks like the patch to libstdc++/3647 was wrong. At this point, rdbuf()->in_avail() is returning 0 for newly opened istreams (that are not empty.). This is incorrect. I suspect that the way to solve this is to set _M_buf and friends to real values instead of indeterminate values in filebuf's ctors. I did work up a partial solution to this based on this approach, but cannot find it at the moment. Here's another testcase for this #include #include #include void test01() { using namespace std; streamsize sum = 0; istringstream iss("shamma shamma"); // test01 size_t i = iss.rdbuf()->in_avail(); cout << i << endl; // test02 size_t max = 0; while (iss.good() && max < 10) { char buf[1024]; streamsize gotten = iss.readsome(buf, sizeof buf); sum += gotten; cout << gotten << " (" << sum << ")" << endl; ++max; } } void test02() { using namespace std; streamsize sum = 0; ifstream ifs(__FILE__); // test01 size_t i = ifs.rdbuf()->in_avail(); cout << i << endl; // test02 size_t max = 0; while (ifs.good() && max < 10) { char buf[1024]; streamsize gotten = ifs.readsome(buf, sizeof buf); sum += gotten; cout << gotten << " (" << sum << ")" << endl; ++max; } } int main() { test01(); test02(); return 0; } http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6746