[cfe-dev] Feature request: C intrinsics for overflow detection

Tobias Grosser tobias at grosser.es
Fri May 9 11:05:44 PDT 2014


On 09/05/2014 19:27, Andy Lutomirski wrote:
> LLVM has the llvm.*.with.overflow.* intrinsics.  Can these be exposed
> to C code?  I imagine this would be straightforward, aside from the
> obligatory bikeshedding about exactly what the interface should be.
>
> This would eliminate a lot of nasty hacks used to check for overflow,
> especially for multiplication overflow.  I currently write this stuff
> in inline x86 assembler -- ugh!  And maybe gcc would go along if clang
> paved the way :)

Is this what you are looking for:

http://llvm.org/releases/3.4/tools/clang/docs/LanguageExtensions.html#checked-arithmetic-builtins

Tobias



More information about the cfe-dev mailing list