GCC Bugzilla has been upgraded from version 4.4.9 to 5.0rc3. If you see any problem, please report it to bug 64968.
Bug 8399 - sync_with_stdio(false) breaks unformatted input
Summary: sync_with_stdio(false) breaks unformatted input
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: ---
Assignee: Paolo Carlini
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-30 02:26 UTC by marc-oliver.gewaltig
Modified: 2003-07-25 17:33 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
get-test.cpp (206 bytes, application/octet-stream)
2003-05-21 15:17 UTC, marc-oliver.gewaltig
Details

Note You need to log in before you can comment on or make changes to this bug.
Description marc-oliver.gewaltig 2002-10-30 02:26:01 UTC
Unformatted input breaks if synchronisation with stdio
is set to false:
istream members
char get()
get(char &)
read(char *, size_t)
will only return on EOF and SIGINT

Release:
gcc 3.1, gcc 3.2

Environment:
Solaris 8, Suse Linux 8.0, and probably all others

How-To-Repeat:
Compile and start the program.
1. the prompt will appear once and get will
   never return. Same applies to other flavours of get
   and read. I did not test getline though.
2.  If sync_with_stdio(false) is removed, the program
   works as expected and shows a prompt after each <RETURN>
Comment 1 Paolo Carlini 2002-11-03 16:09:14 UTC
Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-Why: Analyzed.
Comment 2 Paolo Carlini 2002-11-03 16:09:14 UTC
State-Changed-From-To: open->feedback
State-Changed-Why: On i686-pc-linux-gnu I cannot reproduce the problem with
    current 3.2.1 pre and 3.3 exp.
    Both with and without 'sync' I get:
    ---
    paolo:~/Gcc/PRs/v3/Analyzed> a.out
    c= a
    a
    c=
    
    c= b
    b
    c=
    
    c= q
    q
    ---
    Could you possibly check-out via CVS a 3.2.1 snapshot?
    Otherwise wait just a few days for the upcoming 3.2.1
    release. Please let us know your findings.
    Thanks, Paolo.
Comment 3 Paolo Carlini 2002-11-04 04:53:11 UTC
State-Changed-From-To: feedback->analyzed
State-Changed-Why: For some utterly misterious reason, today I can reproduce
    the problem, both 3.2.1 and 3.3.
    ---
    paolo:~/Gcc/PRs/v3/Analyzed> a.out
    paolo:~/Gcc/PRs/v3/Analyzed> a.out
    c= a
    b
    c
    <ctrl-d>a
    c=
    
    c= b
    c=
    
    c= c
    c=
    
    c= <ctrl-c>
    ---
    Sorry, Paolo.
Comment 4 Paolo Carlini 2002-11-04 04:59:22 UTC
Responsible-Changed-From-To: paolo->unassigned
Responsible-Changed-Why: .
Comment 5 pcarlini 2002-11-10 19:46:41 UTC
From: Paolo Carlini <pcarlini@unitus.it>
To: gcc-gnats@gcc.gnu.org,  gcc-prs@gcc.gnu.org, 
 marc-oliver.gewaltig@hre-ftr.f.rd.honda.co.jp,  gcc-bugs@gcc.gnu.org, 
 nobody@gcc.gnu.org
Cc: bkoz <bkoz@redhat.com>
Subject: Re: libstdc++/8399: sync_with_stdio(false) breaks unformatted input
Date: Sun, 10 Nov 2002 19:46:41 +0100

 Hi,
 
 this is a reduced testcase:
 
 ////
 #include <iostream>
 using namespace std;
 
 int main()
 {
    ios::sync_with_stdio(false);
 
    char c;
 
    cin.get(c);
    cout.put(c);
 
    return 0;
 }
 ////
 
 What happens with current mainline is that a <newline>
 doesn't end the get, whereas this happens with the 'sync'.
 
 Therefore, the issue seems more than vaguely related to
 the obnoxious libstdc++/6745 and all that...
 
 Ciao, Paolo.
 
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8399
 
Comment 6 Paolo Carlini 2002-11-13 12:32:05 UTC
Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-Why: Working (slowly ;) on it...
Comment 7 Paolo Carlini 2002-11-15 00:17:46 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed for 3.3 and 3.2.2 with:
    http://gcc.gnu.org/ml/gcc-patches/2002-11/msg00899.html
Comment 8 Paolo Carlini 2002-11-15 08:06:35 UTC
From: paolo@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: libstdc++/8399
Date: 15 Nov 2002 08:06:35 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	paolo@gcc.gnu.org	2002-11-15 00:06:35
 
 Modified files:
 	libstdc++-v3   : ChangeLog acinclude.m4 configure.in aclocal.m4 
 	                 config.h.in configure 
 	libstdc++-v3/src: ios.cc 
 
 Log message:
 	2002-11-15  Paolo Carlini  <pcarlini@unitus.it>
 	Loren J. Rittle  <ljrittle@acm.org>
 	
 	PR libstdc++/8399
 	* acinclude.m4
 	(GLIBCPP_CHECK_UNISTD_DECL_AND_LINKAGE_1): New macro to
 	check for unistd.h functions.
 	(GLIBCPP_CHECK_UNISTD_SUPPORT): New macro, check for isatty
 	in unistd.h.
 	* configure.in: Call here.
 	* src/ios.cc (ios_base::Init::_S_ios_create(bool)):
 	Use _GLIBCPP_HAVE_ISATTY: ifdef, in case of interactive
 	input __in_size = 1 even when sync_with_stdio is false;
 	otherwise fall back to __in_size = 1.
 	* aclocal.m4: Regenerate.
 	* config.h.in: Regenerate.
 	* configure: Regenerate.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&r1=1.1429&r2=1.1430
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/acinclude.m4.diff?cvsroot=gcc&r1=1.221&r2=1.222
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/configure.in.diff?cvsroot=gcc&r1=1.107&r2=1.108
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/aclocal.m4.diff?cvsroot=gcc&r1=1.232&r2=1.233
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/config.h.in.diff?cvsroot=gcc&r1=1.58&r2=1.59
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/configure.diff?cvsroot=gcc&r1=1.282&r2=1.283
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/src/ios.cc.diff?cvsroot=gcc&r1=1.31&r2=1.32
 
Comment 9 Paolo Carlini 2002-12-02 22:05:22 UTC
From: paolo@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: libstdc++/8399
Date: 2 Dec 2002 22:05:22 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_2-branch
 Changes by:	paolo@gcc.gnu.org	2002-12-02 14:05:21
 
 Modified files:
 	libstdc++-v3   : ChangeLog acinclude.m4 configure.in aclocal.m4 
 	                 config.h.in configure 
 	libstdc++-v3/src: ios.cc 
 	libstdc++-v3/include/bits: streambuf.tcc 
 	libstdc++-v3/testsuite/27_io: ostream_inserter_other.cc 
 
 Log message:
 	2002-12-02  Benjamin Kosnik  <bkoz@redhat.com>
 	Jonathan Lennox  <lennox@cs.columbia.edu>
 	
 	* include/bits/streambuf.tcc (__copy_streambufs):
 	Revert previous fix for the interactive half of
 	libstdc++/6745, use _M_buf_size_opt to set dynamically
 	the correct buffer size.
 	
 	2002-12-02  Jonathan Lennox  <lennox@cs.columbia.edu>
 	
 	* include/bits/streambuf.tcc (__copy_streambufs): verify
 	__sbin->gptr() + __bufsize < __sbin->egptr() before using.
 	* testsuite/27_io/ostream_inserter_other.cc (test_buffer_4): Add.
 	(test05): Use test_buffer_4. Delete unused ostringstream
 	variables.
 	
 	2002-12-02  Paolo Carlini  <pcarlini@unitus.it>
 	
 	PR libstdc++/6745 (continued)
 	* include/bits/streambuf.tcc (__copy_streambufs):
 	Deal with interactive input by using isatty as in the
 	fix for libstdc++/8399.
 	
 	2002-12-02  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
 	
 	* src/ios.cc [_GLIBCPP_HAVE_UNISTD_H]: Include unistd.h.
 	
 	2002-12-02  Paolo Carlini  <pcarlini@unitus.it>
 	Loren J. Rittle <ljrittle@acm.org>
 	
 	PR libstdc++/8399
 	* acinclude.m4
 	(GLIBCPP_CHECK_UNISTD_DECL_AND_LINKAGE_1): New macro to
 	check for unistd.h functions.
 	(GLIBCPP_CHECK_UNISTD_SUPPORT): New macro, check for isatty
 	in unistd.h.
 	* configure.in: Call here.
 	* src/ios.cc (ios_base::Init::_S_ios_create(bool)):
 	Use _GLIBCPP_HAVE_ISATTY: ifdef, in case of interactive
 	input __in_size = 1 even when sync_with_stdio is false;
 	otherwise fall back to __in_size = 1.
 	* aclocal.m4: Regenerate.
 	* config.h.in: Regenerate.
 	* configure: Regenerate.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.1057.2.159.2.60&r2=1.1057.2.159.2.61
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/acinclude.m4.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.194.2.15.2.6&r2=1.194.2.15.2.7
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/configure.in.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.83.2.14.2.4&r2=1.83.2.14.2.5
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/aclocal.m4.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.202.2.16.2.6&r2=1.202.2.16.2.7
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/config.h.in.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.50.2.4.2.2&r2=1.50.2.4.2.3
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/configure.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.235.2.24.2.10&r2=1.235.2.24.2.11
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/src/ios.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.24.2.6.4.1&r2=1.24.2.6.4.2
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/include/bits/streambuf.tcc.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.12.2.2.4.3&r2=1.12.2.2.4.4
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libstdc++-v3/testsuite/27_io/ostream_inserter_other.cc.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.10.2.1.2.1&r2=1.10.2.1.2.2