[fpc-devel] Unreachable code warnings

Florian Klaempfl florian at freepascal.org
Mon Oct 15 10:40:28 CEST 2007


Micha Nelissen schrieb:
> Peter Vreman wrote:
>> There is a good reason for that the unreachable code is a warning: The
>> compiler _changes_ your
>> code by removing the if-branch. When it is a hint the compiler only
>> has recognized a pattern, but
>> it does not modify anything.
> 
> It "changes" it, but semantically it's the same right?
> 
> In your reasoning, the compiler should also emit a warning when it does

There were enough other reasons.

> (or would do) common subexpression extraction.

Anyways, gcc warns similiar, even two times ;):

~> cat test.c
int f(unsigned char c)
{
  if (c<0 || c>255)
    return 1;
  return 0;
}
~> gcc -c test.c
test.c: In function ‘f’:
test.c:3: warning: comparison is always false due to limited range of
data type
test.c:3: warning: comparison is always false due to limited range of
data type

So I guess the warning stays. We can discuss some extensions which makes
it easier to code such restrictions like merging parts of the tue branch.



More information about the fpc-devel mailing list