From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6271 invoked by alias); 23 Jan 2003 19:06: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 6225 invoked by uid 71); 23 Jan 2003 19:06:01 -0000 Resent-Date: 23 Jan 2003 19:06:01 -0000 Resent-Message-ID: <20030123190601.6223.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 4752 invoked by uid 48); 23 Jan 2003 18:58:16 -0000 Message-Id: <20030123185816.4751.qmail@sources.redhat.com> Date: Thu, 23 Jan 2003 19:06: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++/9424: i/ostream::operator>>/<<(streambuf*) drops characters X-SW-Source: 2003-01/txt/msg01391.txt.bz2 List-Id: >Number: 9424 >Category: libstdc++ >Synopsis: i/ostream::operator>>/<<(streambuf*) drops characters >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Thu Jan 23 19:06:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: peturr02@ru.is >Release: gcc-3.2.1 >Organization: >Environment: Red Hat Linux 8.0 >Description: basic_istream<>::operator>>(basic_streambuf<>*) and basic_ostream<>::operator<<(basic_streambuf<>*) drop characters on the floor by extracting characters from the source before they have been successfully inserted into the sink. This seems to happen only if the source is unbuffered, if the source is buffered, extraction happens after insertion as required. >How-To-Repeat: See attachment. >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="streambufcopybug2.cc" Content-Disposition: inline; filename="streambufcopybug2.cc" #include #include #include #include #undef NDEBUG #include using namespace std; class Outbuf : public streambuf { char buf[1]; public: Outbuf() { setp(buf, buf + 1); } int_type overflow(int_type c) { int_type eof = traits_type::eof(); if (pptr() < epptr()) { if (traits_type::eq_int_type(c, eof)) return traits_type::not_eof(c); *pptr() = traits_type::to_char_type(c); pbump(1); return c; } return eof; } }; class Inbuf : public streambuf { static const char buf[]; const char* current; int size; public: Inbuf() { current = buf; size = strlen(buf); } int_type underflow() { if (current < buf + size) return traits_type::to_int_type(*current); return traits_type::eof(); } int_type uflow() { if (current < buf + size) return traits_type::to_int_type(*current++); return traits_type::eof(); } }; const char Inbuf::buf[] = "0123456789"; int main() { Inbuf inbuf1; istream is (&inbuf1); Outbuf outbuf1; is >> &outbuf1; assert(inbuf1.sgetc() == '1'); Outbuf outbuf2; ostream os (&outbuf2); Inbuf inbuf2; os << &inbuf2; assert(inbuf2.sgetc() == '1'); return 0; }