Bug 18861 - ostream width does not work with floats
ostream width does not work with floats
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
7.0
i386 Linux
high Severity high
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
:
: 19183 21199 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-10-10 20:05 EDT by Andrej Filipcic
Modified: 2005-10-31 17:00 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-10-16 11:21:38 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Andrej Filipcic 2000-10-10 20:05:34 EDT
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 04:09:25 EDT
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 11:21:36 EDT
*** Bug 19183 has been marked as a duplicate of this bug. ***
Comment 3 Jakub Jelinek 2000-10-24 04:24:35 EDT
Should be fixed in gcc-2.96-60 in rawhide.
Comment 4 Jakub Jelinek 2000-11-21 15:44:02 EST
*** Bug 21199 has been marked as a duplicate of this bug. ***
Comment 5 Brett S. 2000-11-28 09:48:07 EST
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 09:53:24 EST
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 10:29:39 EST
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.