Skip to content
Advertisement

Why is SIGFPE not triggered after adding a printf line?

I am playing with a simple program (source code below). And my computer configuration:

Linux mymachine 3.13.0-49-generic #83-Ubuntu SMP Fri Apr 10 20:11:33 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)

JavaScript

I intend to trigger the SIGFPE in this program by calling the executable in this way:

JavaScript

As you can see, the SIGFPE is successfully triggered. However, if I uncomment a single printf line in the argument checking “if” condition:

JavaScript

And then I recompile the program and try to trigger SIGFPE using the same way. I only get this:

JavaScript

What is happening?

Advertisement

Answer

Because now your source code is mis-indented compared to how it is actually parsed.

JavaScript

Consider putting both statements in a block instead to avoid this.

Advertisement