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

Serious bug


There is a serious bug either in the compiler or in the library.

The source below must produce the folowing output:
1 
0 
1

On Linux (gcc-2.8.1 and egcs-1.1) I get:
0 
5.11396e-15 
1

On AIX (gcc-2.7.2) the output is correct:
1
0
1


// main.cc

# include <iostream.h>

class X {
  public:
    X(double x, double y) : fx(x), fy(y) {}

    double func() {return fx + fy;}

  private:
    double fx;
    double fy;
};

int main()
{
  X x(100.1, 0.01);
  double x1 = x.func();
  double x2 = x.func();

  cout << (x1 == x.func()) << '\n';
  cout << (x1 - x.func()) << '\n';
  cout << (x1 == x2) << '\n';
}


Ryszard Kabatek
---
Martin-Luther University Halle-Wittenberg
Department of Physical Chemistry
Geusaer Str. 88, 06217 Merseburg, Germany
Tel. +49 3461 46 2487 Fax. +49 3461 46 2129



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