public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/6746: ifstream::readsome() always returns zero
@ 2002-11-23  6:06 bkoz
  0 siblings, 0 replies; 8+ messages in thread
From: bkoz @ 2002-11-23  6:06 UTC (permalink / raw)
  To: bkoz, gcc-bugs, gcc-prs, tony.oliver

Synopsis: ifstream::readsome() always returns zero

State-Changed-From-To: feedback->closed
State-Changed-By: bkoz
State-Changed-When: Mon Nov 18 12:24:13 2002
State-Changed-Why:
    Fixed.

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


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

* Re: libstdc++/6746: ifstream::readsome() always returns zero
@ 2002-11-19 12:32 bkoz
  0 siblings, 0 replies; 8+ messages in thread
From: bkoz @ 2002-11-19 12:32 UTC (permalink / raw)
  To: bkoz, gcc-bugs, gcc-prs, tony.oliver

Synopsis: ifstream::readsome() always returns zero

State-Changed-From-To: open->feedback
State-Changed-By: bkoz
State-Changed-When: Mon Nov 11 15:13:36 2002
State-Changed-Why:
    Fixed. Sorry about the delay.

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


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

* Re: libstdc++/6746: ifstream::readsome() always returns zero
@ 2002-07-04 17:39 bkoz
  0 siblings, 0 replies; 8+ messages in thread
From: bkoz @ 2002-07-04 17:39 UTC (permalink / raw)
  To: bkoz, gcc-bugs, gcc-prs, tony.oliver

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 <fstream>
    #include <sstream>
    #include <iostream>
    
    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


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

* Re: libstdc++/6746: ifstream::readsome() always returns zero
@ 2002-05-29  8:56 bkoz
  0 siblings, 0 replies; 8+ messages in thread
From: bkoz @ 2002-05-29  8:56 UTC (permalink / raw)
  To: bkoz, gcc-bugs, gcc-prs, nobody, tony.oliver

Synopsis: ifstream::readsome() always returns zero

Responsible-Changed-From-To: unassigned->bkoz
Responsible-Changed-By: bkoz
Responsible-Changed-When: Wed May 29 08:09:45 2002
Responsible-Changed-Why:
    Mine.

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


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

* Re: libstdc++/6746: ifstream::readsome() always returns zero
@ 2002-05-26  4:16 Paolo Carlini
  0 siblings, 0 replies; 8+ messages in thread
From: Paolo Carlini @ 2002-05-26  4:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

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

From: Paolo Carlini <pcarlini@unitus.it>
To: tony.oliver@mci.co.uk,  gcc-gnats@gcc.gnu.org,  gcc-prs@gcc.gnu.org, 
 gcc-bugs@gcc.gnu.org
Cc:  
Subject: Re: libstdc++/6746: ifstream::readsome() always returns zero
Date: Sun, 26 May 2002 10:58:07 +0200

 The following is the testcase mentioned by submitter in the PR:
 
 #include <fstream>
 #include <iostream>
 using namespace std;
 
 int main(int, char**)
 {
         streamsize sum = 0;
         ifstream ifs(__FILE__);
 
         while (ifs.good())
         {
                 char buf[1024];
                 streamsize gotten = ifs.readsome(buf, sizeof buf);
                 sum += gotten;
                 cout << gotten << " (" << sum << ")" << endl;
         }
 
         return 0;
 }
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6746 
 
 


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

* Re: libstdc++/6746: ifstream::readsome() always returns zero
@ 2002-05-20 13:39 paolo
  0 siblings, 0 replies; 8+ messages in thread
From: paolo @ 2002-05-20 13:39 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, tony.oliver

Synopsis: ifstream::readsome() always returns zero

State-Changed-From-To: feedback->analyzed
State-Changed-By: paolo
State-Changed-When: Mon May 20 13:39:25 2002
State-Changed-Why:
    Confirmed. The following is a minimal testcase (6746.cc):
    #include <fstream>
    #include <cassert>
    
    int main()
    {
      char str[50];
      std::streamsize count;
      std::ifstream file("6746.cc");
    
      count = file.readsome(str, 50);
    
      assert( count == 50 );
    }

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


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

* Re: libstdc++/6746: ifstream::readsome() always returns zero
@ 2002-05-20 10:57 paolo
  0 siblings, 0 replies; 8+ messages in thread
From: paolo @ 2002-05-20 10:57 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, tony.oliver

Synopsis: ifstream::readsome() always returns zero

State-Changed-From-To: open->feedback
State-Changed-By: paolo
State-Changed-When: Mon May 20 10:57:07 2002
State-Changed-Why:
    For some reason, the source code is missing from your PR. Could you possibly provide it?
    Thanks, Paolo.

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


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

* libstdc++/6746: ifstream::readsome() always returns zero
@ 2002-05-20 10:16 tony.oliver
  0 siblings, 0 replies; 8+ messages in thread
From: tony.oliver @ 2002-05-20 10:16 UTC (permalink / raw)
  To: gcc-gnats


>Number:         6746
>Category:       libstdc++
>Synopsis:       ifstream::readsome() always returns zero
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 20 10:16:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Tony Oliver
>Release:        gcc-3.1
>Organization:
>Environment:
sparc-sun-solaris2.8
Thread model: posix
>Description:
Calling ifstream::readsome() always yields a return value of zero (no bytes read).  No stream error flags are set.  This behaviour has been introduced in release gcc-3.1: it worked fine in gcc-3.0.4.

The problem appears to be confined to the filebuf part of ifstream, not the istream part, since (for instance) istringstream::readsome() does not suffer from this problem.

My installation of gcc-3.1 was configured with the following options (/home/to0001/ is my networked home directory):
--prefix=/home/to0001/app/gcc-3.1
--enable-languages=c,c++
--disable-shared
--verbose

Trivial test program source code attached.

Expected output (as output by gcc-3.0.4 version):

308 (308)
0 (308)

Actual output:

0 (0)
0 (0)
0 (0)
... [forever]
>How-To-Repeat:
g++ -ansi -pedantic -Wall -o gcc-test gcc-test.c++

gcc-test
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

end of thread, other threads:[~2002-11-18 20:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-23  6:06 libstdc++/6746: ifstream::readsome() always returns zero bkoz
  -- strict thread matches above, loose matches on Subject: below --
2002-11-19 12:32 bkoz
2002-07-04 17:39 bkoz
2002-05-29  8:56 bkoz
2002-05-26  4:16 Paolo Carlini
2002-05-20 13:39 paolo
2002-05-20 10:57 paolo
2002-05-20 10:16 tony.oliver

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