Optimizing with dmd disables floating point exceptions

Jens Mueller jens.k.mueller at gmx.de
Fri Apr 29 01:15:31 PDT 2011


KennyTM~ wrote:
> (It seems the message is lost. Let me try again.)
> 
> On Apr 29, 11 15:10, Jens Mueller wrote:
> > KennyTM~ wrote:
> [snip]
> >
> > I think the compiler performs that floating point division at compile
> > time. I should look at the assembly. So the floating point exception
> > happens at that point. Shouldn't the compiler tell me this somehow? Ask
> > differently how do I get to know when my compile time function causes
> > floating point exceptions?
> > Interestingly the results are not the same. Shouldn't in both cases
> > assert(a == real.infinity, to!(string)(a));
> > hold.
> > Without optimization it holds. Why does it not hold with optimizations?
> >
> > Jens
> 
> The compiler (optimizer) recognizes you have provided only constants
> and try to do constant folding. But the backend (evalu8.c) did not
> treat the divide-by-zero case correctly and yields a garbage value.
> 
> See bug 5908 (http://d.puremagic.com/issues/show_bug.cgi?id=5908).

Yeah. Looks like a bug to me as well.

Jens


More information about the Digitalmars-d mailing list