|
From: John R. <re...@cs...> - 2004-01-01 22:46:53
|
A nasty programming bug occurs when you pick an insufficiently large integer type for a variable and it overflow or underflows. Seems like it wouldn't be too hard to develop to valgrind skin that checks for this error. Anybody see obvious problems with this idea? John Regehr |
|
From: Jeremy F. <je...@go...> - 2004-01-02 01:01:09
|
On Thu, 2004-01-01 at 14:46, John Regehr wrote: > A nasty programming bug occurs when you pick an insufficiently large > integer type for a variable and it overflow or underflows. Seems like it > wouldn't be too hard to develop to valgrind skin that checks for this > error. Anybody see obvious problems with this idea? I think there would be far too many false positives. Many programmers and all compilers know enough about twos compliment arithmetic to take advantage of overflow, so there would be many instances of correct usage of overflow and truncation. You need to come up with a more precise definition of what the error case is, and how to distinguish it from correct usage. If you report every instance of overflow or underflow, the tool would be useless for all the messages it generates. J |
|
From: John R. <re...@cs...> - 2004-01-02 18:06:08
|
> You need to come up with a more precise definition of what the error > case is, and how to distinguish it from correct usage. If you report > every instance of overflow or underflow, the tool would be useless for > all the messages it generates. Yeah. My idea here is to use some sort of simple run-time type inference to find a subset of the program variables to track, and then to use lots of heuristics to suppress errors for common compiler and programmer idioms. The main problem with this idea is that where I really want to apply it is to embedded systems where people commonly choose smallish datatypes to save memory and because larger-than-machine-word ints are computationally expensive. Overflow probably isn't that big of a problem for desktop programs these days since most sensible programmers use 32-bit ints pretty widely and these don't overflow that much. Oh well... John |