[cfe-dev] SIGFPE received when a program is compiled with Clang but not with GCC

Reid Kleckner via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 18 10:50:48 PST 2015


LLVM believes that floating point division will never trap, and speculates
it to make code like this:
float tmp = 1.0 / scale;
scale = scale == 0.0 ? scale : tmp;

Normally, FP division produces NaN. The only way that I'm aware of to make
FP div trap is to use fenv.h, which isn't supported:
https://llvm.org/bugs/show_bug.cgi?id=8100

On Wed, Nov 18, 2015 at 2:15 AM, Shriramana Sharma via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hello. I'm using Clang 3.7~svn251177-1~exp1 from the Apt repo on
> Kubuntu Trusty 64 bit. I'm trying to backport Asymptote from Debian
> Sid: https://packages.debian.org/sid/asymptote
>
> I find that the build fails with:
>
> ../asy -dir ../base -config "" -render=0 -f pdf -noprc filegraph.asy
> ../base/plain_Label.asy: 294.10: runtime: Floating point exception (core
> dumped)
>
> When I investigated this I found that there was no problem when
> compiling with GCC.
>
> Please note the attached script which should demonstrate the error.
> Running the script with -g will compile using the "default" compiler
> (gcc) and does not produce any error.
>
> I used KDbg to debug the situation i.e. run the executable asy with
> the given arguments which produced the error during the build and
> found that at pair.h, line 148 reads:
>
> if(scale != 0.0) scale=1.0/scale;
>
> but it is at this point that despite the if() check, during one
> particular invocation to pair unit(const pair&), somehow the program
> is trying to do the division and getting the error.
>
> Note that for some reason during debugging I keep getting SIGPWR,
> SIGXCPU etc – I don't know why this is but it is perhaps because asy
> implements a virtual machine which does not support debugging or such?
> Anyhow, repeatedly trying to run the executable with the given
> arguments produces the error in the end.
>
> --
> Shriramana Sharma ஶ்ரீரமணஶர்மா श्रीरमणशर्मा
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151118/05a0b0cc/attachment.html>


More information about the cfe-dev mailing list