Search code examples
clanguage-lawyerc11c17

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


Follow-up question for: clang: <string literal> + <expression returning int> leads to confusing warning: adding 'int' to a string does not append to the string.

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

Reason: better understanding of the term "strictly conforming program".


Solution

  • An implementation may generate diagnostics even if a program is conforming.

    Section 5.1.1.3p1 of the C standard regarding diagnostics states:

    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

    The portion in bold in footnote 9 states that additional diagnostics may be produced.