K
Keith Thompson
Robert Seacord said:I guess I'm wondering what a constraint violation is. I know a
constraint is defined as a restriction, either syntactic or semantic, by
which the exposition of language elements is to be interpreted.
But doesn't a compliant compiler need to issue a fatal diagnostic for a
constraint violation. Or maybe even a warning?
C99 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.
Footnote:
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.
So a compiler is allowed to produce a non-fatal warning in response to
a constraint violation.