Serious bug

Ryszard Kabatek rysio@rumcajs.chemie.uni-halle.de
Thu Sep 24 09:27:00 GMT 1998


On 24 Sep 1998, Alexandre Oliva wrote:

> 
> Which doesn't mean egcs is wrong.  It's just different, it's a
> rounding problem, with undefined results.
>  
> Alexandre Oliva
 
It is really a problem. 
It does disqualify `float' and `double' 
for a lot of applications on Intel.

The sample below would produce wrong results on Intel, 
but right on other platforms:

class X {
  public:
    X(double x) : fx(x) {}

    double begin() const {return fx - 0.01;}
    double   end() const {return fx + 0.01;}
    
    double value(double t)
    {
      if (t < begin() || t > end()) return 0.0;

      return 1000.0*(end() - t)/(end() - begin());
    }

  private:
    double fx;
};

# include <iostream.h>

int main()
{
  X x(100.5);
  cout << x.value(x.begin()) << '\n'; // --> 0.0 instead of 1000.0
}


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




More information about the Gcc-bugs mailing list