[LLVMdev] Integer divide by zero

Renato Golin renato.golin at linaro.org
Fri Apr 5 12:08:02 PDT 2013


On 5 April 2013 19:40, Joshua Cranmer 🐧 <Pidgeot18 at gmail.com> wrote:

> Per C and C++, integer division by 0 is undefined. That means, if it
> happens, the compiler is free to do whatever it wants. It is perfectly
> legal for LLVM to define r to be, say, 42 in this code; it is not required
> to preserve the fact that the idiv instruction on x86 and x86-64 will trap.
>

Undefined behaviour aside, would be good to have a warning, I think. Does
the static analyser have something like it?

cheers,
--renato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130405/34f9ccd8/attachment.html>


More information about the llvm-dev mailing list