Conformance requirements and #error/#warning
4.1.1 [intro.compliance.general]

Created on 2022-01-13.00:00:00 last changed 2 months ago


Date: 2022-03-27.20:51:22

Suggested resolution:

Add a new paragraph after 4.1.1 [intro.compliance.general] paragraph 2 as follows:

Although this document states only requirements on C++ implementations, those requirements are often easier to understand if they are phrased as requirements on programs, parts of programs, or execution of programs. Such requirements have the following meaning:
  • If a program contains no violations of the rules in Clause Clause 5 [lex] through Clause Clause 33 [thread] and Annex D, a conforming implementation shall, within its resource limits as described in Annex B, accept and correctly execute [ Footnote: ... ] that program.
  • If a program contains a violation of any diagnosable rule or an occurrence of a construct described in this document as “conditionally-supported” when the implementation does not support that construct, a conforming implementation shall issue at least one diagnostic message.
  • If a program contains a violation of a rule for which no diagnostic is required, this document places no requirement on implementations with respect to that program.

[Note: ... — end note]

Furthermore, a conforming implementation

  • shall not accept a translation unit containing a #error preprocessing directive (15.8 [cpp.error]) unless it is part of a group skipped by conditional inclusion (15.2 [cpp.cond]) and
  • shall issue at least one diagnostic message for each #warning or #error preprocessing directive not following a #error preprocessing directive, ignoring #warning and #error preprocessing directives appearing in groups skipped by conditional inclusion.

For classes and class templates, ...

Date: 2022-03-27.20:51:22

According to 4.1.1 [intro.compliance.general] bullet 2.2,

a conforming implementation shall issue at least one diagnostic message

for an ill-formed program that is not “no diagnostic required.” The relationship between this diagnostic message and the ones required by the #error and #warning preprocessor directives is not clear. For example, is an implementation required to emit multiple diagnostics if multiple #error directives are encountered, even though conformance requires only one? Could an implementation count the diagnostic emitted by #warning as satisfying the requirement for an ill-formed program?

See also issue 745.

Date User Action Args
2022-03-27 20:51:22adminsetmessages: + msg6779
2022-01-13 00:00:00admincreate