Omission re static linkage

Walter Murray walter at hpclwjm.HP.COM
Tue Oct 24 05:44:55 AEST 1989


> Consider the following program:

> void f1() {
>   extern void f3(void);  /* [1] */
> }
> void f2() {
>   static void f3(void);  /* [2] */
> }
> static void f3() {       /* [3] */
> }

> According to section 3.1.2.2, declarations [1] and [3] refer to the
> same identifier, and function f3 has internal linkage.  

No, as I read it, the f3 declared in [1] has external linkage because
there is no visible declaration with file scope at that point.  The
f3 declared in [3] does indeed have internal linkage.  Because the
same identifier appears with both external and internal linkage,
behavior is undefined.

> However, the
> standard neglects to state what declaration [2] refers to.

Declaration [2] violates a constraint of 3.5.1:  "The declaration
of an identifier for a function that has block scope shall have no
explicit storage-class specifier other than extern."

> Norman Diamond, Sony Corp.

Walter Murray
----------



More information about the Comp.std.c mailing list