[comp.std.c] Omission re static linkage

diamond@csl.sony.co.jp (Norman Diamond) (10/19/89)

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.  However, the
standard neglects to state what declaration [2] refers to.

-- 
Norman Diamond, Sony Corp. (diamond%ws.sony.junet@uunet.uu.net seems to work)
  Should the preceding opinions be caught or     |  James Bond asked his
  killed, the sender will disavow all knowledge  |  ATT rep for a source
  of their activities or whereabouts.            |  licence to "kill".

walter@hpclwjm.HP.COM (Walter Murray) (10/24/89)

> 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
----------

golson@hpfcso.HP.COM (Will Golson) (10/26/89)

>According to section 3.1.2.2, declarations [1] and [3] refer to the
>same identifier, and function f3 has internal linkage.  However, the
>standard neglects to state what declaration [2] refers to.

Actually, there is a linkage conflict between [1] and [3].  As for
[2], section 3.5.1, under 'Semantics', states that block scope
function declarations shall have no explicit storage-class specifier
other than 'extern'.

Will Golson