libstdc++/10579: showbase fails to include "0x" when value is 0 (whether using standard or deprecated headers)

dclunie@dclunie.com dclunie@dclunie.com
Thu May 1 13:46:00 GMT 2003


>Number:         10579
>Category:       libstdc++
>Synopsis:       showbase fails to include "0x" when value is 0 (whether using standard or deprecated headers)
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 01 13:46:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     dclunie@dclunie.com
>Release:        Any version 3 (last tried it with 3.2.3)
>Organization:
>Environment:
Mac OS X 10.2.5
>Description:
After "setiosflags(ios::showbase)", a value of 1 is correctly displayed as "0x1", but a value of 0 is displayed as "0" when it should be "0x0".

This happens even when a width is set and padding is incorporated (i.e. one gets "000000" rather than "0x0000" with a width of 6 and pad of zero).

E.g. using the following code in "hexpaddinggcc3problem.cc":

#include <iostream.h>
#include <iomanip.h>

or

#include <iostream>
#include <iomanip>
using namespace std;

int main() {
	cout
		<< setiosflags(ios::showbase)
		<< hex
		<< 0
		<< endl
		<< 1
		<< endl
	;
}

One gets:

% g++ -Wno-deprecated -o hexpaddinggcc3problem hexpaddinggcc3problem.cc
% ./hexpaddinggcc3problem
0
0x1
% g++2 -o hexpaddinggcc3problem hexpaddinggcc3problem.cc
[helgray:~/work/experiments] dclunie% ./hexpaddinggcc3problem
0x0
0x1
% g++ -v
Reading specs from /usr/local/lib/gcc-lib/powerpc-apple-darwin6.5/3.2.3/specs
Configured with: ../gcc-3.2.3/configure --prefix=/usr/local
Thread model: single
gcc version 3.2.3
% g++2 -v
Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs
Apple Computer, Inc. version gcc-937.2, based on gcc version 2.95.2 19991024 (release)
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list