"strictly conforming program" + 没有扩展名是否意味着 "no diagnostics emitted"?

Does "strictly conforming program" + no extensions mean "no diagnostics emitted"?

后续问题:

“严格符合程序”+无扩展是否意味着“未发出诊断”?

原因:更好地理解术语“严格符合程序”。

即使程序符合要求,实施也可能会生成诊断信息。

关于诊断状态的 C standard 第 5.1.1.3p1 节:

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.9)


  1. The intent is that an implementation should identify the nature of, and where possible localize, each violation. Of course, an implementation is free to produce any number of diagnostics as long as a valid program is still correctly translated. It may also successfully translate an invalid program

脚注 9 中的粗体部分表示可能会产生额外的诊断。

Does "strictly conforming program" + no extensions == no diagnostics emitted?

没有

语言规范要求发出诊断的唯一内容是无效语法和约束违规:

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.

(C2017,5.1.1.3/1;已强调)

根据定义,严格符合的程序仅展示有效语法且不包含任何约束违规,因此规范不要求符合要求的实现在出现时发出任何诊断信息这样的节目。

但是,规范不禁止实现发出除必需诊断之外的诊断,并且大多数实现在某些情况下会发出不需要的诊断。规范 允许 这一点,正如脚注 9 所阐明的那样,部分内容是:

Of course, an implementation is free to produce any number of diagnostics as long as a valid program is still correctly translated.

另请注意,“'strictly conforming program' + 无扩展名”是多余的。使用任何语言扩展的程序可能符合,但并不严格符合:

A strictly conforming program shall use only those features of the language and library specified in this International Standard. It shall not produce output dependent on any unspecified, undefined,or implementation-defined behavior, and shall not exceed any minimum implementation limit.

(C2017 4/5;已强调)