From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22179 invoked by alias); 14 Feb 2003 07:56:01 -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 22158 invoked by uid 71); 14 Feb 2003 07:56:01 -0000 Resent-Date: 14 Feb 2003 07:56:01 -0000 Resent-Message-ID: <20030214075601.22157.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 18450 invoked by uid 48); 14 Feb 2003 07:53:56 -0000 Message-Id: <20030214075356.18449.qmail@sources.redhat.com> Date: Fri, 14 Feb 2003 07:56: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++/9701: filebuf::sputc, in_avail incorrect X-SW-Source: 2003-02/txt/msg00606.txt.bz2 List-Id: >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 #include 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; }