csignalssigfpe

What is a "FPE_FLTSUB: subscript out of range" signal?


In sys/signal.h, one of the possible codes for a SIGFPE is a FPE_FLTSUB for which the comment just says "subscript out of range -NOTIMP". I'm on OS X 10.9, but it appears to be in glibc as well.

It isn't one of the standard IEEE exceptions, so what is it, and when is it raised?


Solution

  • FreeBSD generates this code with SIGFPE when the x86 BOUND instruction detects an array index out of bounds. It looks like Linux generates SIGSEGV instead.

    This is not particularly important, since the BOUND instruction is best avoided. It is not available in 64-bit mode and on most modern processors it is very slow even if the index is within bounds.