public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: jm@bourguet.org
To: gcc-gnats@gcc.gnu.org
Subject: libstdc++/5820: EOF not handled correctly on input
Date: Sun, 03 Mar 2002 11:16:00 -0000	[thread overview]
Message-ID: <20020303190902.5643.qmail@sources.redhat.com> (raw)


>Number:         5820
>Category:       libstdc++
>Synopsis:       EOF not handled correctly on input
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 03 11:16:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     jm@bourguet.org
>Release:        gcc-3.0.2
>Organization:
>Environment:
Debian Linux
>Description:
On all Unix variants I've tried, programs taking their input from a
terminal consider two CTRL-D (this key can be changed with stty, but
I'll use CTRL-D) in a row or one CTRL-D just at the beginning of a
line as an end of file indication.

With the C++ library furnished with gcc 3.0.2, executing:

#include <iostream>
#include <istream>
#include <ostream>

int main()
{
   int i;
   char c;
   
   std::cout << "Enter an integer: ";
   std::cin >> i;
   if (!std::cin) {
     std::cerr << "Unexpected read problem\n";
     return 1;
   }   
   std::cout << '\n' << "std::cin.eof()=" << std::cin.eof() << '\n';
   std::cout << "The number was: " << i << '\n';
   std::cin >> c;
   if (std::cin) {
     std::cerr << "Could read " << c << " after the number!\n";
   }   
}

on a Linux box with input and output directed to a terminal, I had to
type 4 times CTRL-D after 5 to get the expected result:

Enter an integer: 5
std::cin.eof()=1
The number was: 5

If I type "5", two or three CTRL-D and "a", I get:

Enter an integer: 5a

std::cin.eof()=0
The number was: 5
Could read a after the number!
>How-To-Repeat:
See description
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2002-03-03 19:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-03 11:16 jm [this message]
2002-04-09 14:42 bkoz
2002-04-11  5:46 Jean-Marc Bourguet
2002-04-11  9:56 Benjamin Kosnik
2002-04-13  7:46 Jean-Marc Bourguet
2002-04-30  0:26 bkoz
2002-05-06  6:29 bkoz
2002-06-03 13:16 Jean-Marc Bourguet

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=20020303190902.5643.qmail@sources.redhat.com \
    --to=jm@bourguet.org \
    --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).