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]

[egcs-1.0 i386-redhat-linux] C++: bug in setw() for doubles


Hello all,

I've succesfully build egcs-1.0 on my pentium RedHat-5.0
system. However when trying to use the egcs compiler for my project I
think I've discovered a bug which I narrowed down to the following
piece of code:

  ---code---
  % cat iomanip_bug.cc
  #include <iostream.h>
  #include <iomanip.h>

  int main() 
  {
    cout << setfill('.');
    cout << "int is correct:  '..3' == '" << setw(3) << int(3)    << "'\n";
    cout << "double is wrong: '..3' != '" << setw(3) << double(3) << "'\n";
    return 0;
  }

  ---execution---
  % ./iomanip_bug > bug.out
  % cat bug.out
  int is correct:  '..3' == '..3'
  double is wrong: '..3' != '  3'

When I look in the file bug.out I see that the spaces in the output
above of double(3) actually aren't spaces but '^@' characters. I saw
the same results with the egcs-971114 and egcs-971201 snapshots on the
same machine. I tried the same code with egcs for mips-sgi-irix5.3 and
the problems did not occur, so I think the problem is linux or x86
specific. 

Some more information:

  ---my system and egcs setup---
  RedHat-5.0: i586-pc-linux-gnu
  binutils-2.8.1.0.15

  % cat $EGCS_TREE/config.status
  ./configure --host=i386-redhat-linux --enable-haifa--enable-threads=posix \
      --prefix=/usr --gxx-include-dir=/usr/include/g++ \
      --enable-shared --norecursion 
  # using "config/mh-x86pic" and "config/mt-x86pic"

Regards,

Ard

****************************************************************************
Ard Kuijpers                                       
Faculty of Mechanical Engineering                  e-mail:ard@wfw.wtb.tue.nl
Eindhoven University of Technology                     phone: +31 40 2472811
P.O. Box 513,  5600 MB Eindhoven,  The Netherlands       fax: +31 40 2461418
****************************************************************************
"...Do what makes your heart hurt less..." _follow_your_heart_  THE PALADINS 
****************************************************************************


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