Questions tagged [sigfpe]

On POSIX-compliant platforms, SIGFPE is the signal sent to a process when it encounters an arithmetic error, such as division by zero.

On POSIX-compliant platforms, SIGFPE is the signal sent to a process when it encounters an arithmetic error, such as division by zero.

See Also:

63 questions
73
votes
2 answers

Floating point exception ( SIGFPE ) on 'int main(){ return(0); }'

I am trying to build a simple C program for two different Linux environments. On one device the program runs fine, on the other device the program generates a floating point exception. The program does nothing but return 0 from main which leads me…
Chimera
  • 5,884
  • 7
  • 49
  • 81
17
votes
3 answers

Division by zero does not throw SIGFPE

I have a small program performing floating-point division by zero, so I expect SIGFPE. #include #include #include #include #include void signal_handler (int signo) { if(signo == SIGFPE)…
user707779
10
votes
2 answers

Floating Point Exception Core Dump

I am newbie on the Linux signals, please help. The following code get core dump when run in Linux 2.6 gcc. $ ./a.out Floating point exception (core dumped) The questions: 1. Since a process signal mask is installed, shouldn't the "SIGFPGE" generated…
John Crane
  • 371
  • 5
  • 14
9
votes
1 answer

C++/CLI: SIGFPE, _control87, _fpreset, porting ancient unmanaged Watcom C app to .NET

I have a several-thousand-line application that relies on SIGFPE (handled by a function pointer passed to signal()) to change state and have the code run correctly when certain floating point conditions happen. However, under C++/CLI in…
user343400
  • 171
  • 1
  • 3
8
votes
1 answer

Why was SIGFPE used for integer arithmetic exceptions?

Why was SIGFPE used for integer arithmetic exceptions, such as division by zero, instead of creating a separate signal for integer arithmetic exceptions or naming the signal in the first place for arithmetic exceptions generally?
Eric Postpischil
  • 195,579
  • 13
  • 168
  • 312
7
votes
4 answers

what does C/C++ handler SIGFPE?

well, I have searched the articles about SIGFPE ,then I wrote a few tests but it's behavoir is strange. Then I have to post it here to ask for help. Is the GCC/G++ or ISO C++ clearly defined what happens if divide by zero? 1) I searched the article…
python
  • 1,870
  • 4
  • 24
  • 35
6
votes
1 answer

How to avoid floating point exceptions in unused SIMD lanes

I like to run my code with floating point exceptions enabled. I do this under Linux using: feenableexcept( FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW ); So far so good. The issue I am having, is that sometimes the compiler (I use clang8) decides to…
Bram
  • 7,440
  • 3
  • 52
  • 94
6
votes
1 answer

Stopping the debugger when a NaN floating point number is produced without a code change

I read this and this. The quintessence is that one can throw a SIGFPE if a nan is produced by including fenv.h and enabling all floating point exceptions but FE_INEXACT by feenableexcept(FE_ALL_EXCEPT & ~FE_INEXACT); Thus, the code changes form…
schorsch312
  • 5,553
  • 5
  • 28
  • 57
5
votes
2 answers

What is the difference between underflow and nan in C?

Currently I'm learning about floating point exceptions. I'm writing a loop with a function. In that function a value is calculated that equals 0.5. As the loop proceeds, the input value gets divided by 10. The loop: for(i = 0; i < e; i++) { …
Tim
  • 415
  • 2
  • 10
4
votes
1 answer

Is it possible to catch integer overflow exception in C (POSIX/Linux) via SIGFPE FPE_INTOVF?

I feel like this is a stupid question, but I have found zero information about the topic (not here nor anywhere), so here's the question: Context (what you probably already know): SIGFPE exceptions and si_code field In POSIX/Linux we have a…
Luca Polito
  • 2,387
  • 14
  • 20
4
votes
2 answers

why is there a SIGFPE?

for some reason, it used to work. but now i get a SIGFPE.....what's wrong? #include "usefunc.h" long factorial(long num) { if (num > 1) { long counter; long fact = 1; for (counter = num; counter > 0; counter--) fact *=…
tekknolagi
  • 10,663
  • 24
  • 75
  • 119
4
votes
1 answer

NAN -> distinguish between a division by zero and an exponent with a very large negative value

I included a check for nan's in my testsuite. Now a SIGFPE is thrown at the following line const double retVal =exp(exponent); The exponent has a value of approximately value -4000. This is of course very near to zero and without the nan check the…
schorsch312
  • 5,553
  • 5
  • 28
  • 57
4
votes
1 answer

Floating point exception when reading real values from an input file

I try to read a float value from an input file in Fortran. To do so I use this code : ... INTEGER :: nf REAL :: re OPEN(newunit=nf, file='toto.txt') READ(unit=nf, fmt=*) re ... with toto.txt a text file containing my real…
R. N
  • 707
  • 11
  • 31
4
votes
8 answers

Can I ignore a SIGFPE resulting from division by zero?

I have a program which deliberately performs a divide by zero (and stores the result in a volatile variable) in order to halt in certain circumstances. However, I'd like to be able to disable this halting, without changing the macro that performs…
Mikeage
  • 6,424
  • 4
  • 36
  • 54
4
votes
2 answers

How do you enable floating point exceptions for clang in OS X?

I want my code to terminate when there is a floating point error. In linux-gcc the "feenableexcept()" function does the job, but that isn't available on in OSX. When using gcc on OS X the approach taken in (Enabling floating point interrupts on Mac…
doc07b5
  • 600
  • 1
  • 7
  • 18
1
2 3 4 5