c++/6450: Bad output from iostream using hex format with insertion operato r (<<)

Deborah Schindall dschindall@adirtech.com
Thu Apr 25 07:21:00 GMT 2002


>Number:         6450
>Category:       c++
>Synopsis:       Using hex directive with insertion operator (<<) does not
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 25 07:16:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Deborah Schindall
>Release:        3.0.4
>Organization:
Adir Technologies, Inc.
>Environment:
System: SunOS sundevshared.engineering.netspeak.com 5.8 Generic_108528-13
sun4u sparc SUNW,Ultra-4
Architecture: sun4
host: sparc-sun-solaris2.8
build: sparc-sun-solaris2.8
target: sparc-sun-solaris2.8
configured with: ../gcc-3.0.4/configure --enable-threads=posix
--with-as=/vobs/OEM/gnu/binutils/2.11.2/bin/as
--with-ld=/vobs/OEM/gnu/binutils/2.11.2/bin/ld
--prefix=/vobs/OEM/gnu/gcc/3.0.4 --exec-prefix=/vobs/OEM/gnu/gcc/3.0.4
>Description:
Using fstream or iostream for output to file or standardo out, the directive
"hex" should display the output as a hex number, but actually displays as
some floating point junk.	This code works as expected with the 3.0.2
compiler.
>How-To-Repeat:
#include <iostream>
#include <fstream>
using namespace std;
main()
{
    long    i = 100;
    ofstream des;
    des.open("/tmp/des.out.txt");
    des << hex << i << endl;
    des << dec << i << endl;
    cout << hex << i << endl;
    cout << dec << i << endl;
}

Expect this code to print out "64" and then "100".  But actually outputs
"2.14315e-312" and "100".
I have collected information available.
>Fix:
	not known, Need a workaround or patch.

>Release-Note:
>Audit-Trail:
>Unformatted:
 work correctly.



More information about the Gcc-bugs mailing list