[BUG][GCC] *Serious* optimization bug: Any gcc specialistsoutthere?

Stephan Rudlof sr at evolgo.de
Sun Aug 6 15:06:11 UTC 2000


Arjen van Elteren wrote:
> 
> On Sat, 5 Aug 2000, Stephan Rudlof wrote:
> 
> > Arjen van Elteren wrote:
> > >
> > > Hi stephan,
> > >
> > > I've got the same problem (also the same version)
> > > but could solve it adding
> > > #define __NO_MATH_INLINES
> > > before
> > > #include <math.h>
> > >
> > > Seems to work ok after this...
> >
> > Works for me, too; but with correct or incorrect result
> >       sin(arg1): -7.469219e-01
> > .
> > If the result *would* be correct, this *could* be a workaround; but I think
> > the bug *should* be fixed in the inline implementation.
> >
> > Too many *ould's for my taste here ;-(
> >
> 
> I think that what we are looking at here is no real gcc or even math
> library fault.

I disagree here. IMO the semantics *** must not change *** if I use a -O
flag for compiling or not.
It's worse to get wrong results. But it's more worse to have two *different*
wrong results, than just one wrong result here.

> It is probably an overflow/round-off problem
> (how much accurancy do you need to calculate sin( 1e20 )
>  correctly ?). If you really are interested in the
> correct answer I think you should use a infinite precision library.
> Or you can play around with IEEE settings. See also the gnu scientific library;
> http://sources.redhat.com/gsl/
> 
> As has been noted before the actual CPU might have the deciding call
> on the calculation of sin(1e20).

The man page of sin() should specify what the valid argument range is for
optimized or not optimized version. Or is there any other document with a
clear specification?

Some more observations for arg 1.0e20:

- __STRICT_ANSI__ leads to the same result -7.469219e-01 with or without
optimization;
- errno isn't set to EDOM for all cases (opt on/off, strict ANSI on/off),
but it should for invalid args!

Greetings,

Stephan


> I can live with a different answer as long as it is correct and faster
> for real cases ( [-1eX , -1e-Y] and [1eY,1eX] ) ( X and Y to be determined but always smaller then 20 )
> 
> Arjen

-- 
Stephan Rudlof (sr at evolgo.de)
   "Genius doesn't work on an assembly line basis.
    You can't simply say, 'Today I will be brilliant.'"
    -- Kirk, "The Ultimate Computer", stardate 4731.3





More information about the Squeak-dev mailing list