[Bug c/12738] Missing function with 'static' block-scope declaration; unit-at-a-time; and IMA.

wilson at specifixinc dot com gcc-bugzilla@gcc.gnu.org
Fri Oct 31 02:20:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12738



------- Additional Comments From wilson at specifixinc dot com  2003-10-31 02:06 -------
Subject: Re:  Missing function with 'static' block-scope declaration;
 unit-at-a-time; and IMA.

pinskia at gcc dot gnu dot org wrote:
> int
> flarm(void)
> {
>   extern int i;
>   return i;


> }
> static int i;

This is a rather different testcase.  ISO C says that functions declared 
within a block may not be declared static, so Geoff's example is 
immediately invalid.

This one is trickier though.  An extern int declaration within a block 
is certainly valid.  And the scope of a declaration within a block ends 
at the end of the block, so there are no conflicting declarations that 
require a diagnositic.  ISO C does say that if the same identifier is 
defined within different linkage within a module that the effect is 
undefined, so this testcase does have undefined effect, but we aren't 
required to emit a diagnostic for it.

By the way, gcc did used to give a warning for this testcase with -Wall. 
  I wrote the code myself, it was the IDENTIFIER_LIMBO_VALUE stuff in 
c-decl.c.  This was removed by Zack in April this year.  gcc-3.3 does 
warn, but gcc-3.4 does not.  This might be an accidental misfeature of 
Zack's patch, as the patch itself claims to preserve the functionality 
of IDENTIFIER_LIMBO_VALUE, but implement it a different way.  I did not 
verify that Zack's patch is the problem though.  The problem could have 
been created by some other patch unrelated to Zack's changes.  I'd 
suggest looking at Zack's patch first though, if we care.  The patch is
     http://gcc.gnu.org/ml/gcc-patches/2003-04/msg00766.html



More information about the Gcc-bugs mailing list