C99 prohibits an "inline definition" of a function with external linkage
from containing modifiable static variables or references to file-scope
static variables or functions.

A definition is an inline definition only if all file-scope declarations
for the function in the translation unit use "inline" and do not use
"extern".  Thus, this cannot be determined until the end of the translation
unit.  GCC gives the diagnostics for the above constraint too soon, leading
to the following valid examples being wrongly rejected with -std=c99
-pedantic-errors.  It needs to defer them and see at the end of the
translation unit whether the definition is an inline definition after all.

Example 1:
static int a;
inline int f (void) { return a; }
int f (void);

Example 2:
inline void f (void) { static int a; }
extern inline void f (void);


-- 
           Summary: statics in C99 inline functions later declared extern
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jsm28 at gcc dot gnu dot org
OtherBugsDependingO 16989
             nThis:


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

Reply via email to