Bug 22776 - calling iostream's width fn results in filling with null characters
Summary: calling iostream's width fn results in filling with null characters
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc   
(Show other bugs)
Version: 7.0
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
Depends On:
TreeView+ depends on / blocked
Reported: 2000-12-23 07:13 UTC by jbednar
Modified: 2007-04-18 16:30 UTC (History)
0 users

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

Attachments (Terms of Use)

Description jbednar 2000-12-23 07:13:27 UTC
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 08:46:04 UTC
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 17:48:10 UTC
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.