Title
#error disallows existing implementation practice
Status
drwp
Section
4.1.1 [intro.compliance.general]
Submitter
Richard Smith

Created on 2023-02-13.00:00:00 last changed 4 months ago

Messages

Date: 2024-01-21.13:30:12

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.

Date: 2023-03-07.22:58:33

CWG 2023-03-03

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

Date: 2023-06-13.20:20:09

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.
Date: 2024-03-15.00:00:00

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

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

  • The requirement to issue a diagnostic message for each appearance of #warning conflicts with existing implementations having a diagnostic limit. Furthermore, an implementation with an on-the-fly incremental preprocessor is no longer allowed to abort the compilation when an error deemed fatal happens (e.g. a #include file that does not exist).
  • The wording does not allow for implementation-specific mechanisms for creating a preprocessing translation unit, such as vendor-specific forms of #if-like directives and #pragma once.
History
Date User Action Args
2024-07-20 13:52:34adminsetstatus: dr -> drwp
2024-04-05 21:43:46adminsetstatus: ready -> dr
2024-03-20 14:10:31adminsetstatus: tentatively ready -> ready
2024-01-21 13:30:12adminsetstatus: review -> tentatively ready
2023-03-07 22:58:33adminsetmessages: + msg7219
2023-03-07 22:58:33adminsetmessages: + msg7218
2023-03-07 22:58:33adminsetstatus: open -> review
2023-02-27 21:04:26adminsetmessages: + msg7211
2023-02-13 00:00:00admincreate