具有内部链接的变量的暂定定义具有不完整的非数组类型:一致的实现显示不同的行为

Tentative definition of variable with internal linkage has incomplete non-array type: conforming implementations show different behavior

后续问题:

上下文:具有内部链接的变量的暂定定义具有不完整的非数组类型:一致的实现显示不同的行为。

示例代码(t940.c):

static struct s foo;
static struct s {int a;} foo;

调用:

$ gcc t940.c -c -std=c11 -pedantic -Wall -Wextra -Wno-unused-variable
<nothing>    

$ clang t940.c -c -std=c11 -pedantic -Wall -Wextra -Wno-unused-variable
t940.c:1:17: warning: tentative definition of variable with internal linkage has incomplete non-array type 'struct s' [-Wtentative-definition-incomplete-type]
static struct s foo;
                ^
t940.c:1:15: note: forward declaration of 'struct s'
static struct s foo;
              ^
1 warning generated.

$ cl t940.c /c /std:c11 /Za
Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30133 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

t940.c
t940.c(1): error C2079: 'foo' uses undefined struct 's'
t940.c(2): error C2371: 'foo': redefinition; different basic types
t940.c(1): note: see declaration of 'foo'

$ icl t940.c -c -std=c11 -pedantic -Wno-unused-variable
<nothing> 

现场演示:https://godbolt.org/z/9j8E1634q

工具版本:

$ gcc --version
gcc (GCC) 11.2.0

$ clang --version
clang version 13.0.0

$ cl
Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30133 for x64

# icl is x86-64 icc 2021.1.2 (from godbolt.org)

问题:根据 C11,哪种行为是正确的?

UPD1。创建时间:https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102821.

来自 C 标准(6.9.2 外部对象定义)

3 If the declaration of an identifier for an object is a tentative definition and has internal linkage, the declared type shall not be an incomplete type.

和(4.一致性)

1 In this International Standard, ‘‘shall’’ is to be interpreted as a requirement on an implementation or on a program; conversely, ‘‘shall not’’ is to be interpreted as a prohibition.