News for hackers. Stuff that matters.
Re:Understanding Integer Overflow in C/C++ (2012) [pdf] by nkurz on Saturday July 09, 2016 @06:41PM (#12063676)
Do there exist any good tools for identifying undefined behavior in C or C++ code? Compiler warnings are getting better, and "sanitizers" can catch undefined behavior that actually happens at runtime, but I still haven't found anything that consistently catches unwanted optimizations based on compiler assumptions of "no undefined behavior".

Stack (https://css.csail.mit.edu/stack/) is the best tool that I've found, and while it's a great start, it's extremely difficult to install, clumsy to use, doesn't appear to have been touched in years, and only catches a limited subset of constructs. Is there anything else out there? If not, is it because it's perceived as too difficult to do, or is it just not perceived as a need?

Re:Understanding Integer Overflow in C/C++ (2012) [pdf] by tacostakohashi on Saturday July 09, 2016 @07:59PM (#12063916)
Probably Coverity (http://www.synopsys.com/software/coverity/Pages/default.aspx) is the best / most complete implementation of this idea.

Although it has impressive capabilities, you'll need to deal with their sales people, get a license, and invest a non-trivial amount of time learning the system, modifying your software build, etc, to get a lot out of in. Unless your code is mission-critical, it's probably more trouble than it's worth.

Re:Understanding Integer Overflow in C/C++ (2012) [pdf] by telotortium on Saturday July 09, 2016 @06:59PM (#12063717)
Not all undefined behavior can be caught at compile time.

However, LLVM and GCC can detect a lot of undefined behavior at runtime with ubsan. I'm not sure how much performance penalty there is. Presumably checks are added on every signed integer arithmetic operation, pointer dereference, etc., but some checks can probably be removed by the optimizer (for example, a branch may be taken if a pointer is not null, which means the optimizer can remove all null checks in that branch as long as the pointer hasn't been modified).

Edit: oops, I missed the part where you said you're aware of sanitizers.

Re:Understanding Integer Overflow in C/C++ (2012) [pdf] by Too on Sunday July 10, 2016 @04:02AM (#12064898)
GCC has -fsanitize which is pretty good.