允许您关闭标准要求的诊断的实现是否仍然符合标准?
Is an implementation that allows you turn off diagnostics required by the standard still conforming?
考虑以下因素:
typedef int;
int main () { return 0; }
如果我用没有警告规范的 clang 编译它,我得到
warning: typedef requires a name [-Wmissing-declarations]
typedef int;
这是意料之中的;根据 C11 标准的第 6.7 节和第 5.1.1.3 节,typedef int
是非法的,
A conforming implementation shall produce at least one diagnostic message if a preprocessing translation unit or translation unit contains a violation of any syntax rule or constraint.
如果我使用 clang -Wno-missing-declarations
编译它,它编译干净,没有任何诊断消息。
我的问题:
这会将 clang 标记为不合格的实现,还是可以提供禁用强制诊断的能力?
从草案 C11 标准部分 4
Conformance 我们看到它不严格符合:
A strictly conforming program shall use only those features of the
language and library specified in this International Standard.3) It
shall not produce output dependent on any unspecified, undefined, or
implementation-defined behavior, and shall not exceed any minimum
implementation limit.
但它是一个一致的实现,因为一个一致的实现允许有扩展,只要它们不破坏一个严格一致的程序:
[...]A conforming implementation may have extensions (including
additional library functions), provided they do not alter the behavior
of any strictly conforming program.4)
[...]There are very few realistic, useful, strictly conforming programs. On the other hand, a merely conforming program can make use of any compiler-specific extension it wants to.
考虑以下因素:
typedef int;
int main () { return 0; }
如果我用没有警告规范的 clang 编译它,我得到
warning: typedef requires a name [-Wmissing-declarations]
typedef int;
这是意料之中的;根据 C11 标准的第 6.7 节和第 5.1.1.3 节,typedef int
是非法的,
A conforming implementation shall produce at least one diagnostic message if a preprocessing translation unit or translation unit contains a violation of any syntax rule or constraint.
如果我使用 clang -Wno-missing-declarations
编译它,它编译干净,没有任何诊断消息。
我的问题:
这会将 clang 标记为不合格的实现,还是可以提供禁用强制诊断的能力?
从草案 C11 标准部分 4
Conformance 我们看到它不严格符合:
A strictly conforming program shall use only those features of the language and library specified in this International Standard.3) It shall not produce output dependent on any unspecified, undefined, or implementation-defined behavior, and shall not exceed any minimum implementation limit.
但它是一个一致的实现,因为一个一致的实现允许有扩展,只要它们不破坏一个严格一致的程序:
[...]A conforming implementation may have extensions (including additional library functions), provided they do not alter the behavior of any strictly conforming program.4)
[...]There are very few realistic, useful, strictly conforming programs. On the other hand, a merely conforming program can make use of any compiler-specific extension it wants to.