<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57480>57480</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Possibly wrong error: redeclaration of 'x' with a different type
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          pmor13
      </td>
    </tr>
</table>

<pre>
    This C code:
```
static int (*x)[];

void f1(void)
{
    extern int (*x)[3];
}

void f2(void)
{
    extern int (*x)[5];
}
```
leads to:
```
error: redeclaration of 'x' with a different type: 'int (*)[5]' vs 'int (*)[3]'
    extern int (*x)[5];
                 ^
<source>:5:18: note: previous declaration is here
    extern int (*x)[3];
```
which is unexpected because the previous declaration is invisible.

Relevant quote from C11, 6.2.2 Linkages of identifiers, 4:
> 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. If no prior declaration is visible, or if the prior
declaration specifies no linkage, then the identifier has external linkage.

For identifier `x` in function `f2` declaration of identifier `x` in function `f1` is invisible. Hence, there is no need to check for type compatibility. I see it this way. Other C experts are welcome. GCC generates no diagnostics (even under `-std=c11 -pedantic -Wall -Wextra -Wno-unused-variable`).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydVV2P6jYQ_TXJy4gojgmBhzzsZXfbSpVaVZX67CRj4l5jp7YD7L_vOAldYPdKvRdB8Md45pwz40lju7f6z1552ENrO0z4U5I_J_lTssmX7zT1QQTVgjIBkmKbFE-XpNgl5ZekfE74l-XI9DxZ1YFkZBVH0WrerBYroA9eAjrz0Ru_c1c9f_Rb_JDf8nO_9xQ1is5DsN-SAJ2zjjbBYYetFo4UsQaspFgVBargrEIPAjolJTokEOFtiIpGg3dMN5DozMl_tsvn3e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