From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20100 invoked by alias); 3 Mar 2002 19:16:03 -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 20053 invoked by uid 71); 3 Mar 2002 19:16:01 -0000 Resent-Date: 3 Mar 2002 19:16:01 -0000 Resent-Message-ID: <20020303191601.20052.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, jm@bourguet.org Received:(qmail 5645 invoked by uid 61); 3 Mar 2002 19:09:02 -0000 Message-Id:<20020303190902.5643.qmail@sources.redhat.com> Date: Sun, 03 Mar 2002 11:16:00 -0000 From: jm@bourguet.org Reply-To: jm@bourguet.org To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: libstdc++/5820: EOF not handled correctly on input X-SW-Source: 2002-03/txt/msg00079.txt.bz2 List-Id: >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 #include #include 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: