Bug 18861 - ostream width does not work with floats
Summary: ostream width does not work with floats
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.0
Hardware: i386
OS: Linux
high
high
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
URL:
Whiteboard:
: 19183 21199 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-10-11 00:05 UTC by Andrej Filipcic
Modified: 2005-10-31 22:00 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2000-10-16 15:21:38 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2000:132 0 normal SHIPPED_LIVE Bug fixing update of GCC 2.96 2000-12-19 05:00:00 UTC

Description Andrej Filipcic 2000-10-11 00:05:34 UTC
The following code produces wrong output:
---------
#include <iostream.h>

int main() {
  int width=cout.precision()+7;
  cout<<width<<endl;
  for (int i=0;i<10;i++) {
    cout.width(width);
    cout<<double(i)<<" ";
  }
  cout<<endl;

  return 0;
}
---------
Output file contains null characters instead of spaces:
---------
13
^@^@^@^@^@^@^@^@^@^@^@^@0 ^@^@^@^@^@^@^@^@^@^@^@^@1
^@^@^@^@^@^@^@^@^@^@^@^@2 ^@^@^@^@^@^@^@^@^@^@^@^@3
^@^@^@^@^@^@^@^@^@^@^@^@4 ^@^@^@^@^@^@^@^@^@^@^@^@5
^@^@^@^@^@^@^@^@^@^@^@^@6 ^@^@^@^@^@^@^@^@^@^@^@^@7
^@^@^@^@^@^@^@^@^@^@^@^@8 ^@^@^@^@^@^@^@^@^@^@^@^@9

Output with ints works ok.
The same holds for gcc version 2.97 20001002 (experimental)

Comment 1 Jakub Jelinek 2000-10-11 08:09:25 UTC
Thanks, I have fixed this, see
http://gcc.gnu.org/ml/gcc-patches/2000-10/msg00305.html
The fix will appear in the next gcc errata.

Comment 2 Jakub Jelinek 2000-10-16 15:21:36 UTC
*** Bug 19183 has been marked as a duplicate of this bug. ***

Comment 3 Jakub Jelinek 2000-10-24 08:24:35 UTC
Should be fixed in gcc-2.96-60 in rawhide.

Comment 4 Jakub Jelinek 2000-11-21 20:44:02 UTC
*** Bug 21199 has been marked as a duplicate of this bug. ***

Comment 5 Brett S. 2000-11-28 14:48:07 UTC
Installing gcc-2.96-64.i386.rpm (and the other gcc packages of this version) from Rawhide did not fix this problem for me. ^@ is still used to space certain types of output.

Comment 6 Jakub Jelinek 2000-11-28 14:53:24 UTC
Have you installed libstdc++-2.96-64.i386.rpm? Aren't the programs statically
linked (in that case they would have to be relinked)?

Comment 7 Brett S. 2000-11-28 15:29:39 UTC
My apologies -- upgrading libstdc++ did fix the problem.


Note You need to log in before you can comment on or make changes to this bug.