'C++ - How to debug SIGILL ILL_ILLOPN

Recently I ran into a crash while the following statement is getting executed

static const float kDefaultTolerance = DoubleToFloat(0.25);

where DoubleToFloat is defined as below

 static inline float DoubleToFloat(double x){
    return static_cast<float>(x);
 }

And the log statements shows below

09-04 01:08:50.727   882   882 F DEBUG   : signal 4 (SIGILL), code 2 (ILL_ILLOPN), fault addr 0x7f9e3ca96818

when I read about SIGILL, I understand that it happens when process encounters to run an invalid operation. So I think compiler (clang in my case) is generating some junk code while translating the above snippet. How to check what is compiler generating and see what is going wrong in this particular case? Also suggest me if there are any tools to debug these kind of issues.



Solution 1:[1]

I have a similar problem today.Finally, I found the reason for the problem is that AVX instruction set is used in floating-point operation, but the computer does not support AVX instruction set. You can try to use SSE Instruction set.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vip??