This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libstdc++/7989: ios::showbase doesn't work when outputting 0


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]