public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: peturr02@ru.is
To: gcc-gnats@gcc.gnu.org
Subject: libstdc++/9661: cin.rdbuf()->sputbackc() does not put characters back to stdin
Date: Tue, 11 Feb 2003 12:56:00 -0000	[thread overview]
Message-ID: <20030211124802.19144.qmail@sources.redhat.com> (raw)


>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 <cstdio>
#include <iostream>

#undef NDEBUG
#include <cassert>

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;
}


             reply	other threads:[~2003-02-11 12:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-11 12:56 peturr02 [this message]
2003-05-16 20:00 bkoz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030211124802.19144.qmail@sources.redhat.com \
    --to=peturr02@ru.is \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).