This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-11-11


2700. #error disallows existing implementation practice

Section: 4.1.1  [intro.compliance.general]     Status: DRWP     Submitter: Richard Smith     Date: 2023-02-13     Liaison: WG14

[Accepted as a DR at the March, 2024 meeting.]

The resolution for issue 2518 disallows existing implementation practice, as detailed below:

Suggested resolution [SUPERSEDED]:

  1. Change in 4.1.1 [intro.compliance.general] paragraph 2 as follows:

    Furthermore, a conforming implementation
    • shall not accept a preprocessing translation unit containing a #error preprocessing directive (15.8 [cpp.error]), and
    • shall issue at least one diagnostic message for each #warning or #error preprocessing directive not following a #error preprocessing directive in a preprocessing translation unit, and
    • shall not accept a translation unit with a static_assert-declaration that fails (9.1 [dcl.pre]).
  2. Change in 5.1 [lex.separate] paragraph 1 as follows:

    The text of the program is kept in units called source files in this document. A source file together with all the headers (16.4.2.3 [headers]) and source files included (15.3 [cpp.include]) via the preprocessing directive #include, less any source lines skipped by any of the conditional inclusion (15.2 [cpp.cond]) preprocessing directives or by the implementation-defined behavior of any conditionally-supported-directives (15.1 [cpp.pre]), is called a preprocessing translation unit.

CWG 2023-03-03

Permit that #warning can be ignored if another diagnostic is produced.

Proposed resolution (approved by CWG 2024-01-19):

  1. Change in 4.1.1 [intro.compliance.general] bullet 2.3 as follows:

    • ...
    • Otherwise, if a program contains
      • a violation of any diagnosable rule or,
      • a preprocessing translation unit with a #warning preprocessing directive (15.8 [cpp.error]), 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.
  2. Change in 4.1.1 [intro.compliance.general] paragraph 2 as follows:

    Furthermore, a conforming implementation shall not accept
    • a preprocessing translation unit containing a #error preprocessing directive (15.8 [cpp.error]), or
    • shall issue at least one diagnostic message for each #warning or #error preprocessing directive not following a #error preprocessing directive in a preprocessing translation unit, and
    • shall not accept a translation unit with a static_assert-declaration that fails (9.1 [dcl.pre]).
  3. Change in 5.1 [lex.separate] paragraph 1 as follows:

    The text of the program is kept in units called source files in this document. A source file together with all the headers (16.4.2.3 [headers]) and source files included (15.3 [cpp.include]) via the preprocessing directive #include, less any source lines skipped by any of the conditional inclusion (15.2 [cpp.cond]) preprocessing directives, as modified by the implementation-defined behavior of any conditionally-supported-directives (15.1 [cpp.pre]) and pragmas (15.9 [cpp.pragma]), if any, is called a preprocessing translation unit.
  4. Change in 15.8 [cpp.error] as follows:

    A preprocessing directive of either of the following forms the form
    # error pp-tokensopt new-line
    
    renders the program ill-formed. A preprocessing directive of the form
    # warning pp-tokensopt new-line
    
    causes requires the implementation to produce a at least one diagnostic message for the preprocessing translation unit (4.1.1 [intro.compliance.general]) that.

    Recommended practice: Any diagnostic message caused by either of these directives should include the specified sequence of preprocessing tokens; the #error directive renders the program ill-formed.