Authors: Jay Ghiron
Date: 2026-11-09
Submitted against: C23
Status: Open
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 are not required to be produced in other circumstances.
(C23 5.2.1.3 "Diagnostics" paragraph 1.)
This paragraph makes the distinction between constraint violations and violations of a syntax rule, however the following does not:
In this document, "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.
If a "shall" or "shall not" requirement that appears outside of a constraint or runtime-constraint is violated, the behavior is undefined. Undefined behavior is otherwise indicated in this document by the words "undefined behavior" or by the omission of any explicit definition of behavior. There is no difference in emphasis among these three; they all describe "behavior that is undefined".
A program that is correct in all other aspects, operating on correct data, containing unspecified behavior shall be a correct program and act in accordance with 5.2.2.4.
(C23 4 "Conformance" paragraphs 1, 2, and 3.)
Therefore it seems like programs containing syntactical errors can still be considered correct programs. This is surely not intended.
Modify C23 4 paragraph 3:
A program containing no violations of any syntax rule, that is correct in all other aspects, operating on correct data, containing unspecified behavior shall be a correct program and act in accordance with 5.2.2.4.
Note: An alternative approach could be to make a violation of any syntax rule a constraint violation as well. For example, this could be done right at the start of C23 6.1. This would remove the need to distinguish violations of syntax rules from constraint violations.