suspicious error 'static declaration follows non-static declaration'

Andrew Makhorin mao@gnu.org
Sun Feb 18 13:05:00 GMT 2018


> I think it is about fixing a conceptual bug given the following example:
> 
> extern int i;  // external linkage
> int f() {
>   static int i;  // internal linkage
>   {
>     extern int i;  // external linkage before the change, internal
> linkage after the change
>   }
> }
> 
> I think the conceptual bug is because people expect the innermost i to
> follow the i whose enclosing scope is most immediate.
> 

Sorry for off-topic, but I see nothing wrong in your example. The
innermost i being redeclared is not related to the static i, so both
innermost and outermost i's represent the same object having external
linkage.


Andrew Makhorin



More information about the Gcc-help mailing list