From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24358 invoked by alias); 11 Feb 2003 12: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 24336 invoked by uid 71); 11 Feb 2003 12:56:01 -0000 Resent-Date: 11 Feb 2003 12:56:01 -0000 Resent-Message-ID: <20030211125601.24335.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 19145 invoked by uid 48); 11 Feb 2003 12:48:02 -0000 Message-Id: <20030211124802.19144.qmail@sources.redhat.com> Date: Tue, 11 Feb 2003 12: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++/9661: cin.rdbuf()->sputbackc() does not put characters back to stdin X-SW-Source: 2003-02/txt/msg00494.txt.bz2 List-Id: >Number: 9661 >Category: libstdc++ >Synopsis: cin.rdbuf()->sputbackc() does not put characters back to stdin >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Tue Feb 11 12: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: According to this posting to comp.lang.c++.moderated by Matt Austern: fxtk8ha83sv.fsf@isolde.engr.sgi.com cin.rdbuf()->sputbackc(c) and ungetc(c, stdin) should be equivalent and interchangable. Although this is a QoI issue, it seems logical to fix this since * cin.rdbuf()->sbumpc() and fgetc(stdin) are equivalent; * characters returned by cin.rdbuf()->sgetc() can be consumed by both cin.rdbuf()->sbumpc() and fgetc(stdin) * characters put back by ungetc will be returned by cin; that is, cin.rdbuf()->sputbackc is the only case where the effect on cin and stdin differs. >How-To-Repeat: See attachment. >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="stdiosync.cc" Content-Disposition: inline; filename="stdiosync.cc" #include #include #undef NDEBUG #include int main() { using namespace std; int c1 = fgetc(stdin); int c2 = cin.rdbuf()->sputbackc(c1); assert(c2 == c1); int c3 = fgetc(stdin); assert(c3 == c1); ungetc(c3, stdin); int c4 = cin.rdbuf()->sgetc(); assert(c4 == c3); return 0; }