This is the mail archive of the gcc-bugs@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]

c++/1076: g++ 2.96 formatting doubles outputs nulls



>Number:         1076
>Category:       c++
>Synopsis:       g++ 2.96 formatting doubles outputs nulls
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 16 12:46:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     sullivan@mathcom.com
>Release:        g++ 2.96
>Organization:
>Environment:
RedHat 7.0 on Pentium, with all update rpms as of Dec 10, 2000.
$ uname -a
Linux random 2.2.16-22enterprise #1 SMP Tue Aug 22 16:29:32 EDT 2000 i686 unknown
>Description:
g++ or glibc outputs extra null chars '\0'
when formatting doubles.  Example below,
courtesy of jwe@bevo.che.wisc.edu.
>How-To-Repeat:
$ uname -a
Linux random 2.2.16-22enterprise #1 SMP Tue Aug 22 16:29:32 EDT 2000 i686 unknown

$ g++ --version
2.96

$ cat tempa.c
#include <iomanip>
#include <iostream>
int
main (void)
{
  cout << setw (11) << setprecision (4);
  cout.flags (ios::scientific);
  cout << 1.23456789 << endl;
  return 0;
}

$ g++ -o tempa tempa.c

$ ./tempa | tr '\0' X  
X1.2346e+00


Note the leading X, which was a null char.
If you don't do the "tr" command, it will APPEAR to be correct,
since most terminals won't print the null.
>Fix:
None.
>Release-Note:
>Audit-Trail:
>Unformatted:

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