How to declare identifier with internal-linkage in block-scope without prior declaration of that identifier with some linkage being visible?
<p>Consider this:</p>

<pre><code>#include &lt;stdio.h&gt;

static int b;

int main()
{
    {
        int b;

        {
            extern int b;

            b = 2;
        }
    }

    printf("%d", b);
}
</code></pre>

<p>Here by definition the identifier 'b' which is assigned the value 2 must have be the one with external linkage. However for some reason the 'clang' C compiler doesn't complain and the output of this code is '2'.</p>

<p>I'm assuming this because of $6.2.2.4 point in the C standard:</p>

<blockquote>
  <p>For an identifier declared with the storage-class specifier extern in
  a scope in which a prior declaration of that identifier is visible,31)
  if the prior declaration specifies internal or external linkage, the
  linkage of the identifier at the later declaration is the same as the
  linkage specified at the prior declaration. <strong>If no prior declaration is
  visible, or if the prior declaration specifies no linkage, then the
  identifier has external linkage</strong>.</p>
</blockquote>

<p>And as the previous visible declaration specifies no linkage ('int b').</p>

<p>Anyhow how can I make the declaration before the assignment to refer to the identifier with internal linkage (instead of the one with external such).</p>

<p>Edit: I see that this example is UB but this doesn't change my question.</p>