[fpc-devel] Unreachable code warnings
daniel.mantione at freepascal.org
Sun Oct 14 20:57:30 CEST 2007
Op Sun, 14 Oct 2007, schreef Micha Nelissen:
> Daniël Mantione wrote:
> > It is justified to warn, since in some cases an error situation can occur
> > but the way the check is written causes a dead code check. We found a few
> > of these in the compiler sources.
> A warning should always be fixable and doing so, turning it into correct
> code. The compiler is simply wrong here; my code is correct, so it
> should not complain.
The warning is fixable: Remove the superfluous check.
> It's not the compiler's responsibility that the code is correct; that is
> my responsibility, but if it knows for sure it can help me. It's a bit
> like the uninitialized variable warning, which the compiler can't know
> for sure as well.
If the compiler is sure your code is incorrect, it should give an error.
However, unreachable code is just an indication something can be wrong and
therefore a warning is more in place. There is still the issue of the
false positives versus correct positives ratio, but this looks actually
very good for this specific warning.
More information about the fpc-devel