In fact, in the course of our work, we have found that even experts writing safe integer libraries or tools to detect integer errorssometimes make mistakes due to the subtleties of C/C++ semantics for numerical operations

Another nail in the coffin for the meme that "good programmers don't write code with undefined behavior".

Almost all the integers I use in 'C' are highly constrained. I try very hard ( and nearly always succeed ) in writing code that manages those constraints properly. This may include oversubscribing integers - using a long long instead of a long, perhaps.

This involves at least doing a depth-first examination of all invocations of that operation, and possibly writing tests for all of them. That encourages keeping things local.

I think the safety-think here is slightly inappropriate. Of course you can do it wrong. But it is in no way an unreasonable expectation that you not do that.

And again- for the general population out there - perhaps 'C' is not for you. I am a 'C' programmer only because of path dependencies in what's happened to me. I would not recommend it to anyone. That's not elitist - it's just how things played out.

Have you tried using tis-interpreter [0] (an interpreter of C for detecting undefined behavior written in OCaml) written by Pascal Cuoq [1].

[0] https://github.com/TrustInSoft/tis-interpreter

[1] http://stackoverflow.com/users/139746/pascal-cuoq