This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: libstdc++/7989: ios::showbase doesn't work when outputting 0
- From: paolo at gcc dot gnu dot org
- To: gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, lennox at cs dot columbia dot edu, nobody at gcc dot gnu dot org, paolo at gcc dot gnu dot org
- Date: 26 Sep 2002 19:44:00 -0000
- Subject: Re: libstdc++/7989: ios::showbase doesn't work when outputting 0
- Reply-to: paolo at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, lennox at cs dot columbia dot edu, nobody at gcc dot gnu dot org, paolo at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
Synopsis: ios::showbase doesn't work when outputting 0
Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Thu Sep 26 12:44:00 2002
Responsible-Changed-Why:
Analyzed.
State-Changed-From-To: open->closed
State-Changed-By: paolo
State-Changed-When: Thu Sep 26 12:44:00 2002
State-Changed-Why:
Not a bug: gcc-2.95.2 is *incorrect*.
Indeed, for simplicity sake, compare
<C>:
#include <stdio.h>
int main()
{
printf("%#x\n", 5);
printf("%#x\n", 0);
return 0;
}
vs <C++>:
#include <iostream>
using namespace std;
int main()
{
cout.setf(ios::showbase);
cout.setf(ios::hex, ios::basefield);
cout << 5 << endl;
cout << 0 << endl;
}
Only with gcc-3.1 the output is the same for both, that is:
0x5
0
In fact, the ISO/IEC Standard 14882 for C++ prescribes (22.2.2.2.2 and table 57) that the output must be identical to that obtained with the "%#x" format for the C library
function printf().
Thanks for your report, Paolo.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7989