public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* libstdc++/9701: filebuf::sputc, in_avail incorrect
@ 2003-02-14  7:56 peturr02
  0 siblings, 0 replies; 3+ messages in thread
From: peturr02 @ 2003-02-14  7:56 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9701
>Category:       libstdc++
>Synopsis:       filebuf::sputc, in_avail incorrect
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 14 07:56:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     peturr02@ru.is
>Release:        gcc-3.2.1
>Organization:
>Environment:
Red Hat Linux 8.0
>Description:
filebuf::sputc does not always call overflow when pptr() >= epptr().
filebuf::in_avail does not return egptr() - gptr() if it follows sputbackc.
>How-To-Repeat:
See attachment.
>Fix:

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

#include <fstream>
#include <cassert>

using namespace std;

bool called = false;

class dfbuf : public filebuf
{
public:
  const char* pub_epptr() const
  {
    return epptr();
  }

  const char* pub_egptr() const
  {
    return egptr();
  }

  const char* pub_gptr() const
  {
    return gptr();
  }

  const char* pub_pptr() const
  {
    return pptr();
  }

  virtual int overflow(int c)
  {
    called = true;
    return filebuf::overflow(c);
  }
};

void test01()
{
  dfbuf df1;
  df1.open("tmp", ios_base::in | ios_base::out | ios_base::trunc);

  // File empty -> no get buffer available
  assert(df1.pub_gptr() == df1.pub_egptr());

  assert(df1.pub_pptr() == df1.pub_epptr());
  called = false;
  df1.sputc('a');
  assert(called);
}

void test02()
{
  dfbuf df2;
  df2.open("tmp", ios_base::in | ios_base::out | ios_base::trunc);

  df2.sputn("0123456789", 10);

  df2.pubseekoff(0, ios_base::beg);
  df2.sbumpc();
  
  df2.sputbackc('a');
  assert(df2.pub_gptr() < df2.pub_egptr());
  assert(df2.in_avail() == df2.pub_egptr() - df2.pub_gptr());
}

int main()
{
  //test01();
  test02();

  return 0;
}


^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: libstdc++/9701: filebuf::sputc, in_avail incorrect
@ 2003-02-23 17:17 paolo
  0 siblings, 0 replies; 3+ messages in thread
From: paolo @ 2003-02-23 17:17 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, peturr02

Synopsis: filebuf::sputc, in_avail incorrect

State-Changed-From-To: open->analyzed
State-Changed-By: paolo
State-Changed-When: Sun Feb 23 17:17:50 2003
State-Changed-Why:
    The first part (about sputc) is fixed by the work for 9404
    (in fact is not true anymore that pptr == epptr, since the
    latter points to the end of the buffer, 8192 chars wide, by
    default). The second part stands.

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


^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: libstdc++/9701: filebuf::sputc, in_avail incorrect
@ 2003-05-18  8:09 paolo
  0 siblings, 0 replies; 3+ messages in thread
From: paolo @ 2003-05-18  8:09 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, peturr02

Synopsis: filebuf::sputc, in_avail incorrect

State-Changed-From-To: analyzed->closed
State-Changed-By: paolo
State-Changed-When: Sun May 18 08:09:35 2003
State-Changed-Why:
    Fixed for 3.4.

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


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

end of thread, other threads:[~2003-05-18  8:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-14  7:56 libstdc++/9701: filebuf::sputc, in_avail incorrect peturr02
2003-02-23 17:17 paolo
2003-05-18  8:09 paolo

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