libstdc++/9533: Regression: Can't read from tty with ifstream
peturr02@ru.is
peturr02@ru.is
Sat Feb 1 12:16:00 GMT 2003
>Number: 9533
>Category: libstdc++
>Synopsis: Regression: Can't read from tty with ifstream
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Feb 01 12:16:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: peturr02@ru.is
>Release: gcc version 3.3 20030106 (prerelease)
>Organization:
>Environment:
Red Hat Linux 8.0
>Description:
If /dev/tty is opened with an ifstream, nothing can be read. The attached program exits immediately when compiled with gcc-20030106, but outputs the prompt and then waits for input when compiled with gcc-3.2.1.
[petur@interim ttybug]$ g++321 -v
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2.1/specs
Configured with: ../gcc-3.2.1/configure --program-suffix=321 --enable-threads=posix --enable-version-specific-runtime-libs --enable-languages=c,c++
Thread model: posix
gcc version 3.2.1
[petur@interim ttybug]$ g++0106 -v
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/specs
Configured with: ../gcc-20030106/configure --program-suffix=0106 --enable-threads=posix --enable-version-specific-runtime-libs --enable-languages=c,c++ --enable-clocale=gnu
Thread model: posix
gcc version 3.3 20030106 (prerelease)
[petur@interim ttybug]$ rm ttybug && make CXX=g++321
g++321 -static ttybug.cc -o ttybug
[petur@interim ttybug]$ ./ttybug < /dev/zero > /dev/null
Enter a number: 4
You entered: 4
[petur@interim ttybug]$ rm ttybug && make CXX=g++0106
g++0106 -static ttybug.cc -o ttybug
[petur@interim ttybug]$ ./ttybug < /dev/zero > /dev/null
Enter a number: You entered: -1073743396
>How-To-Repeat:
See attachment.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="ttybug.cc"
Content-Disposition: inline; filename="ttybug.cc"
#include <fstream>
int main()
{
using namespace std;
ifstream in ("/dev/tty");
ofstream out ("/dev/tty");
in.tie(&out);
out << "Enter a number: ";
int i;
in >> i;
out << "You entered: " << i << endl;
return 0;
}
More information about the Gcc-bugs
mailing list