home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / gnu / g / lib / bug / 798 < prev    next >
Encoding:
Text File  |  1993-01-25  |  2.5 KB  |  61 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!cs.rice.edu!dougm
  2. From: dougm@cs.rice.edu (Doug Moore)
  3. Newsgroups: gnu.g++.lib.bug
  4. Subject: 2.3: bogus failstate in getline
  5. Date: 25 Jan 1993 20:27:44 -0500
  6. Organization: GNUs Not Usenet
  7. Lines: 48
  8. Sender: daemon@cis.ohio-state.edu
  9. Approved: bug-lib-g++@prep.ai.mit.edu
  10. Distribution: gnu
  11. Message-ID: <9301240857.AA27362@cs.rice.edu>
  12.  
  13. As the following program indicates, when getline is called with a
  14. buffersize of n and n-1 characters are put in the buffer, the state of
  15. the istream is changed to fail.  This is inappropriate and contrary to
  16. the behavior of Sun C++.  The line in igetline.C that brings this
  17. about is easy to find and remove, but I hesitate.  It must be there
  18. for some reason, right?
  19.  
  20. Program:
  21. ====================================================================
  22. #include <iostream.h>
  23.  
  24. main()
  25. {
  26.   char buf[10];
  27.   cin.getline(buf, sizeof(buf));
  28.   cout << "Buffer is: " << buf << endl;
  29.   cout << "cin state is " << cin.rdstate() << endl;
  30. }
  31. ====================================================================
  32. Output compiled with g++, libg++, input "abcdefghijklmnopqrstuvwxyz"
  33. ====================================================================
  34. Buffer is: abcdefghi
  35. cin state is 2
  36. ====================================================================
  37. Output compiled with Sun C++, same input
  38. ====================================================================
  39. Buffer is: abcdefghi
  40. cin state is 0
  41. ====================================================================
  42. Verbose compiler output:
  43. ====================================================================
  44. g++ -o a.out -Wall -v bug.cc
  45. Reading specs from /blossom/lib/gcc-lib/sun4/2.3.3/specs
  46. gcc version 2.3.3
  47.  /blossom/lib/gcc-lib/sun4/2.3.3/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix -Wall bug.cc /usr/tmp/cca27304.i
  48. GNU CPP version 2.3.3 (sparc)
  49.  /blossom/lib/gcc-lib/sun4/2.3.3/cc1plus /usr/tmp/cca27304.i -quiet -dumpbase bug.cc -Wall -version -o /usr/tmp/cca27304.s
  50. GNU C++ version 2.3.3 (sparc) compiled by GNU C version 2.3.3.
  51.  as -o /usr/tmp/cca273041.o /usr/tmp/cca27304.s
  52.  /blossom/lib/gcc-lib/sun4/2.3.3/ld -e start -dc -dp -o a.out /lib/crt0.o -L/blossom/lib/gcc-lib/sun4/2.3.3 -L/blossom/lib /usr/tmp/cca273041.o -lg++ -lgcc -lc -lgcc
  53. ====================================================================
  54.  
  55. Both the compiler and library have been patched a bit.  The system is
  56. sunos 4.1.2, on a sparc.
  57.  
  58. Doug Moore
  59. (dougm@cs.rice.edu)
  60.  
  61.