[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Having fun with the following C code (UB)



Russ Allbery wrote:
> Shachar Shemesh <shachar@debian.org> writes:
>> Do you really want to get a "Warning: signed integer overflow yields
>> undefined behavior" on this function?
> 
> I would certainly like to be able to enable such a thing.  I write a lot
> of code where I'd love the compiler to double-check that I've established
> bounds checks on a and b before doing the addition that guarantee that it
> won't overflow.

Not quite to that point, but you might be interested in the UBS:

http://clang.llvm.org/docs/UsersManual.html#controlling-code-generation

More specifically, two options: -fsanitize=undefined and -fsanitize=integer

And some nice examples:
http://blog.regehr.org/archives/1054
http://blog.regehr.org/archives/963

Cheers,
-- 
Raphael Geissert - Debian Developer
www.debian.org - get.debian.net


Reply to: