public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* libstdc++/7989: ios::showbase doesn't work when outputting 0
@ 2002-09-20 9:16 lennox
0 siblings, 0 replies; 3+ messages in thread
From: lennox @ 2002-09-20 9:16 UTC (permalink / raw)
To: gcc-gnats
>Number: 7989
>Category: libstdc++
>Synopsis: ios::showbase doesn't work when outputting 0
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Sep 20 09:16:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: lennox@cs.columbia.edu
>Release: gcc-3.1
>Organization:
>Environment:
>Description:
When I run the attached program, I expect to see the output
0x0005
0x0000
Instead, with gcc 3.1, I get
0x0005
000000
gcc 2.95.2 is correct, so this is a regression.
>How-To-Repeat:
Compile and run the attached program.
>Fix:
None known.
As a workaround, don't use ios::showbase, and instead output the 0x explicitly.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="fmt-test.cxx"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="fmt-test.cxx"
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aW9tYW5pcD4KCnVzaW5nIG5hbWVzcGFjZSBz
dGQ7CgppbnQgbWFpbigpCnsKICBjb3V0LnNldGYoaW9zOjpzaG93YmFzZSk7CiAgY291dC5zZXRm
KGlvczo6aW50ZXJuYWwsIGlvczo6YWRqdXN0ZmllbGQpOwogIGNvdXQuc2V0Zihpb3M6OmhleCwg
aW9zOjpiYXNlZmllbGQpOwogIGNvdXQuZmlsbCgnMCcpOwogIAogIGNvdXQgPDwgc2V0dyg2KSA8
PCA1IDw8IGVuZGw7CiAgY291dCA8PCBzZXR3KDYpIDw8IDAgPDwgZW5kbDsKCn0K
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: libstdc++/7989: ios::showbase doesn't work when outputting 0
@ 2002-09-27 7:36 Jonathan Lennox
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Lennox @ 2002-09-27 7:36 UTC (permalink / raw)
To: paolo; +Cc: gcc-prs
The following reply was made to PR libstdc++/7989; it has been noted by GNATS.
From: Jonathan Lennox <lennox@cs.columbia.edu>
To: paolo@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org,
nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Cc:
Subject: Re: libstdc++/7989: ios::showbase doesn't work when outputting 0
Date: Fri, 27 Sep 2002 10:34:33 -0400
On , September 26 2002, "paolo@gcc.gnu.org" wrote to "gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, lennox@cs.columbia.edu, nobody@gcc.gnu.org, paolo@gcc.gnu.org" saying:
> 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.
Ah yes, and 9899-1999 says "for x (or X) a non-zero result has 0x (or 0X)
prefixed to it." How odd, but I agree this behavior is correct.
Thanks.
--
Jonathan Lennox
lennox@cs.columbia.edu
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: libstdc++/7989: ios::showbase doesn't work when outputting 0
@ 2002-09-26 12:44 paolo
0 siblings, 0 replies; 3+ messages in thread
From: paolo @ 2002-09-26 12:44 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, lennox, nobody, paolo
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-09-27 14:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-20 9:16 libstdc++/7989: ios::showbase doesn't work when outputting 0 lennox
2002-09-26 12:44 paolo
2002-09-27 7:36 Jonathan Lennox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).