Bug 22776 - calling iostream's width fn results in filling with null characters
calling iostream's width fn results in filling with null characters
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
Depends On:
  Show dependency treegraph
Reported: 2000-12-23 02:13 EST by jbednar
Modified: 2007-04-18 12:30 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2000-12-23 03:46:07 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description jbednar 2000-12-23 02:13:27 EST
gcc-2.96-69's iostream implementation fills with nulls instead of a real
character when a specific width is selected.  E.g.:

> cat bug22.c
#include <iostream>
int main(int, char**)
  std::cout << 0.5 << endl;
  std::cout.fill(' ');
  std::cout << 0.5 << endl;
> g++ -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.0)
> g++ bug22.c -o bug22
> ./bug22

Here I've rendered the nulls (0x00) the way Emacs does (^@), so that they
will survive email.  The same thing happens if the explicit setting of the
fill character is omitted; in either case GCC 2.95 produces a space and
2.96 produces nulls.  The behavior is particularly troublesome when the
output is then converted into a string using strstream, since the resulting
string will be empty due to the bogus nulls.
Comment 1 Jakub Jelinek 2000-12-23 03:46:04 EST
Have you upgraded libstdc++ as well? This was fixed in libstdc++-2.96-60
or before (I don't remember exact release).
Comment 2 jbednar 2000-12-23 12:48:10 EST
D'oh!  Yes, that fixes it; I didn't see that libstdc++ and cpp were also
upgraded when gcc was.  So it works fine in the current release,
libstdc++-2.96-69.  Sorry about that!

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