SIGILL on Sparc

Paolo Bonzini bonzini@gnu.org
Tue Oct 6 09:52:00 GMT 2009


> The function SetCategory(v) returns void and simply assigns
> the value of v to a class member, so there are no trap conditions.
> TA, on the other hand, stands for "trap always", so the condition
> code is unimportant anyway. Why has the trap instruction been generated?

Usually this is because you have code with undefined behavior, that the 
compiler cannot make sense of.  One typical case is casting a function 
that is inlined:

   static inline __attribute__ ((always_inline)) int x(int x)
   {
   }

   ...

   ((float (*) (float)) x) (1.0);

The compiler cannot raise a compile-time error, so the best it can do is 
raise a warning (you probably have one, otherwise it is a bug in GCC) 
and compile the call to a run-time trap.  It can do this because the 
code is undefined in the first place.

Paolo



More information about the Gcc mailing list