1

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?

Simon Byrne
  • 7,694
  • 1
  • 26
  • 50
  • It's for accessing outside the bounds of an array. – Barmar Nov 20 '14 at 23:16
  • @Barmar Do you have any more info or links? I thought C arrays weren't bounds checked: is it guaranteed to always signal on out of bounds access? – Simon Byrne Nov 21 '14 at 09:15
  • They aren't required to be bounds-checked. But that doesn't mean they couldn't be. If an implementation checks bounds, they could use this signal to report it. Also, C isn't the only language in the world, other languages do bounds checking. – Barmar Nov 21 '14 at 15:56
  • Note also that it says "Not implemented". It's just a placeholder for a signal to be used if such a thing is ever implemented. – Barmar Nov 21 '14 at 15:57
  • Ahh, I didn't get the acronym. thanks. – Simon Byrne Nov 21 '14 at 16:52

1 Answers1

1

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.

jilles
  • 10,509
  • 2
  • 26
  • 39