Joe Buck wrote:
On Mon, Apr 14, 2008 at 06:42:30PM -0400, Robert Dewar wrote:
[In fact,
after GCC does something to warn users about this, it'll be
much "safer" than those other compilers.]
For sure you want a warning, the compiler should never be
removing explicit tests in the users code without generating
a warning I would think.
I vaguely recall a paper from Dawson Engler's group (the people who
did the Stanford Checker and Coverity) about warnings for dead code
removal. They are often bugs if seen in straight-line code, but
macros as well as inlining of functions will produce many warnings
of this kind. They focused their work on addressing what the user
could be expected to know, the idea being to issue warnings if
the code on a single level is redundant, but suppress warnings
if the redundant text came from macros or inlining.
Right, we have heuristics in the Ada front end along these lines.
For instance, you generally want to be warned if a test is
always true or always false, but if the test is
if XYZ then
where XYZ is a boolean constant, then probably this is
conditional compilation type activity that is legitimate.