Unused variable but no warning

Russ Allbery rra at stanford.edu
Sun Aug 3 19:47:59 UTC 2008

Julien ÉLIE <julien at trigofacile.com> writes:

> It is strange that gcc does not complain about an unused variable in
> innd/perl.c:
> /* From art.c.  Ew.  Need header parsing that doesn't use globals. */
> extern char             *filterPath;
> at the beginning of this file.  filterPath was previously used when the
> Path: header was parsed in this file but it is no longer the case.
> If I remove that extern declaration, gcc does not complain either.
> Therefore, I think it can be removed.  But it is strange that gcc does
> not see that during "make warnings".

gcc can't warn about non-static globals since it doesn't know if the
variable is referenced in some other translation unit.  It would need to
analyze the whole program at link time to ensure that it was unused.

Russ Allbery (rra at stanford.edu)             <http://www.eyrie.org/~eagle/>

    Please send questions to the list rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.

More information about the inn-workers mailing list