[LLVMdev] Integer divide by zero

Krzysztof Parzyszek kparzysz at codeaurora.org
Sat Apr 6 09:16:27 PDT 2013


On 4/6/2013 3:07 AM, Cameron McInally wrote:
>
> Please don't misunderstand, I'm not trying to be unreasonable about this
> behaviour change. I do believe that there are a few strong arguments for
> this behaviour that we haven't touched upon yet. I also believe that
> this option would be an improvement to LLVM overall. But, I also haven't
> heard anyone in the community voicing interest. So, if no one speaks up
> and would like to discuss further, I'll be happy to keep such a change
> in my local branch.

The IBM XLC compiler has a -qcheck option, which takes arguments 
specifying what type of runtime checks are performed.  For example, 
-qcheck=divzero would cause the program to abort with a SIGTRAP if a 
division by zero was detected (the compiler would insert a conditional 
trap instruction).

Producing a diagnostic message is one way to address this[1], but 
generating some sort of an exception has its merits as well---it all 
depends on the specific situation.  I don't think that the existence of 
one precludes the other.

[1] I've never used fsanitize---this is based on what I've read in the 
clang's manual.

-Krzysztof


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation



More information about the llvm-dev mailing list