缺少具有非保留标识符的对象/函数的定义是否应该导致诊断?

Should missing definition of object / function with non-reserved identifier lead to diagnostics?

示例代码:

void accept(int x);

int main(void)
{
        accept(0);
        return 0;
}

调用:

$ gcc t719.c -std=c11 -pedantic -Wall -Wextra
<nothing>

$ clang t719.c -std=c11 -pedantic -Wall -Wextra
<nothing>

$ cl t719.c /std:c11 /Za
t719.obj : error LNK2019: unresolved external symbol accept referenced in function main

$ icc t719.c -std=c11 -pedantic -Wall -Wextra
<nothing>

考虑到用户忘记定义 accept。我们看到可能不会产生任何诊断。是否需要诊断?

UPD:另一个例子:

extern int y0;

int main(void)
{
        return y0;
}

# linux (begin)
$ gcc t719.c -std=c11 -pedantic -Wall -Wextra
undefined reference to `y0'

$ clang t719.c -std=c11 -pedantic -Wall -Wextra
undefined reference to `y0'

$ icc t719.c -std=c11 -pedantic -Wall -Wextra
<nothing>
# program returned: 243
# linux (end)

# windows (begin)
# gcc in cygwin
$ gcc t719.c -std=c11 -pedantic -Wall -Wextra
<nothing>
# program returned: 255

# clang in cygwin
$ clang t719.c -std=c11 -pedantic -Wall -Wextra
<nothing>
# program returned: 255

$ cl t719.c /std:c11 /Za
unresolved external symbol _y0 referenced in function _main

$ LLVM/12.0.0/bin/clang t719.c -std=c11 -pedantic -Wall -Wextra
<nothing>
# program returned: 72

$ icl -Qstd=c11 t719.c 
<nothing>
# program returned: 65
# windows (end)

C 2018 §6.9 ¶5 说:

… If an identifier declared with external linkage is used in an expression (other than as part of the operand of a sizeof or _Alignof operator whose result is an integer constant), somewhere in the entire program there shall be exactly one external definition for the identifier;…

由于违反了“应”,但它不在约束段落中,C 2018 §4 ¶2 做出了这种未定义的行为:

If a "shall" or "shall not" requirement that appears outside of a constraint or runtime-constraint is violated, the behavior is undefined…

关于诊断的条款,§5.1.1.3,不需要对此进行诊断:

A conforming implementation shall produce at least one diagnostic message (identified in an implementation-defined manner) if a preprocessing translation unit or translation unit contains a violation of any syntax rule or constraint, even if the behavior is also explicitly specified as undefined or implementation-defined. Diagnostic messages need not be produced in other circumstances.