gordon%stats.ucl.ac.uk@NSS.CS.UCL.AC.UK (Gordon Joly Statistics UCL) (01/10/89)
The following program compiles and runs with g++ 1.32 under SunOS 3.4 on a SUN 3/160. gdb+ version 2.8.1. 9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9 1 #include <stream.h> 2 3 main() 4 { 5 char c; 6 7 switch (cin.rdstate()){ 8 case _good: cerr << "Status good\n"; break; 9 case _eof: cerr << "Status eof\n"; break; 10 case _fail: cerr << "Status fail\n"; break; 11 case _bad: cerr << "Status bad\n"; break; 12 default: cerr << "PANIC"; 13 } 14 cerr.flush(); 15 while ( cin.get(c) ) 16 { 17 cerr << " Char was : "; cerr.put(c); cerr << "\n"; 18 switch (cin.rdstate()){ 19 case _good: cerr << "Status good\n"; break; 20 case _eof: cerr << "Status eof\n"; break; 21 case _fail: cerr << "Status fail\n"; break; 22 case _bad: cerr << "Status bad\n"; break; 23 default: cerr << "PANIC"; 24 } 25 cerr.flush(); 26 } 27 cerr << "ABOUT TO DIE\n"; 28 switch (cin.rdstate()){ 29 case _good: cerr << "Status good\n"; break; 30 case _eof: cerr << "Status eof\n"; break; 31 case _fail: cerr << "Status fail\n"; break; 32 case _bad: cerr << "Status bad\n"; break; 33 default: cerr << "PANIC"; 34 } 35 cerr.flush(); 36 } 9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9 Here is the tail of the gdb+ output. 9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9 (gdb+) i b Breakpoints: Num Enb Address Where #1 y 0x0000243e in main (nod3.cc line 27) #2 y 0x00002334 in main (nod3.cc line 18) (gdb+) Bpt 2, main () (nod3.cc line 18) 18 switch (cin.rdstate()){ 1: cin = { <struct File> = {fp = 0x20850, nm = 0x235bc "(stdin)", rw = 1 '\001', state = _good, stat = 0} members of struct istream: tied_to = 0x0} (gdb+) c Continuing. Status good ^D Bpt 1, main () (nod3.cc line 27) 27 cerr << "ABOUT TO DIE\n"; 1: cin = { <struct File> = {fp = 0x20850, nm = 0x235bc "(stdin)", rw = 1 '\001', state = 3, stat = 0} members of struct istream: tied_to = 0x0} ^^^^^^^^^ (gdb+) c ^^^^^^^^^ Continuing. ABOUT TO DIE PANIC Program exited with code 070. (gdb+) 9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9 Should cin.state be 3 ? Cf page 238, Section 8.4.2 of Stroustrup. Please send a copy of any reply to me directly. Thanks, Gordon Joly. Surface mail: Dr. G.C.Joly, Department of Statistical Science, University College London, Gower Street, LONDON WC1E 6BT, U.K. E-mail: | Tel: +44 1 387 7050 JANET (U.K. network) gordon@uk.ac.ucl.stats | extension 3636 (Arpa/Internet form: gordon@stats.ucl.ac.uk)| FAX: +44 1 387 8057 Relays: ARPA @nss.cs.ucl.ac.uk | EAN: @ean-relay.ac.uk | CSNET: %nss.cs.ucl.ac.uk@relay.cs.net | BITNET: %ukacrl.bitnet@cunyvm.cuny.edu, @ac.uk EARN: @ukacrl.bitnet, @AC.UK, @uk.ac.earn-relay By uucp/Usenet: ....!uunet!mcvax!ukc!stats.ucl.ac.uk!gordon