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

  1. Path: sparky!uunet!stanford.edu!agate!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!niwot.scd.ucar.edu!cruff
  2. From: cruff@niwot.scd.ucar.edu (Craig Ruff)
  3. Newsgroups: gnu.g++.lib.bug
  4. Subject: Possible output field adjustment bug
  5. Date: 26 Jan 1993 22:17:14 -0500
  6. Organization: GNUs Not Usenet
  7. Lines: 39
  8. Sender: daemon@cis.ohio-state.edu
  9. Approved: bug-lib-g++@prep.ai.mit.edu
  10. Distribution: gnu
  11. Message-ID: <9301261812.AA00515@maroon.scd.ucar.edu>
  12.  
  13. I have found a possible bug in the field adjustment operators of the stream
  14. class.  The following program:
  15.  
  16. #include <iostream.h>
  17.  
  18. main()
  19. {
  20.     cout.width(4);
  21.     cout << '(' << -12 << ")\n";
  22.  
  23.     cout.width(4);
  24.     cout.setf(ios::left, ios::adjustfield);
  25.     cout << '(' << -12 << ")\n";
  26.  
  27.     cout.width(4);
  28.     cout.setf(ios::internal, ios::adjustfield);
  29.     cout << '(' << -12 << ")\n";
  30. }
  31.  
  32. Produces:
  33.    (-12)
  34. (   -12)
  35.    (-12)
  36.  
  37. According to page 343 of Stroustrup's "The C++ Programming Language", 2nd
  38. edition it should produce:
  39. ( -12)
  40. (-12 )
  41. (- 12)
  42.  
  43. The width function should apply to the next numeric or string output
  44. operation, not to characters.  Now, to me, it would seem that symmetric
  45. operation of the field adjustments are desirable.  Is this the intent
  46. of the libg++ versions?
  47. Craig Ruff          NCAR            cruff@ncar.ucar.edu
  48. (303) 497-1211      P.O. Box 3000
  49.             Boulder, CO  80307
  50.  
  51.  
  52.