fmod nan_mix usage
Steve Kargl
sgk at troutmask.apl.washington.edu
Mon Jul 23 21:59:31 UTC 2018
On Tue, Jul 24, 2018 at 07:41:17AM +1000, Bruce Evans wrote:
> On Mon, 23 Jul 2018, Steve Kargl wrote:
> >
> > Can you share the code for the relevant tests?
> > This simple program gives the expected results
> > on amd64.
> >
> > #include <math.h>
> > #include <stdio.h>
> >
> > int
> > main(void)
> > {
> > printf("%e %d\n", fmodf(3.f, 0.f), isnan(fmodf(3.f, 0.f)));
> > printf("%le %d\n", fmod(3.0, 0.0), isnan(fmod(3.0, 0.0)));
> > printf("%Le %d\n", fmodl(3.L, 0.L), isnan(fmodl(3.L, 0.L)));
> > return 0;
> > }
> >
> > % cc -o z -O a.c -lm && ./z
> > nan 1
> > nan 1
> > nan 1
>
> clang normally evaluates this at compile, so it doesn't test the libary.
> This is arguably a bug in clang, since it doesn't set the exception flags.
> #pragma FENV_ACCESS should control this, but it is hard to use and rarely
> works.
>
> The test data needs to be non-literal and perhaps even volatile to prevent
> the compiler evaluating it at compile time.
>
Whoops. I should know better! I have -fno-builtins hardcoded
in my development trees and completely forgot about constant
folding.
--
Steve
More information about the freebsd-numerics
mailing list