Title
Interaction of constant expression changes with preprocessor expressions
Status
open
Section
15.2 [cpp.cond]
Submitter
Richard Smith

Created on 2012-01-02.00:00:00 last changed 24 months ago

Messages

Date: 2022-11-20.07:54:16

CWG 2022-11-11

A possible approach, in addition to the proposed resolution above, is to prohibit the [ and { pp-tokens in the controlling expression of a conditional inclusion. C++ also permits using the alternative tokens, e.g. not, which might need clarification in the wording.

Date: 2022-03-15.00:00:00

Additional note (March, 2022):

The proposed resolution shown above allows lambda-expressions, which is undesirable.

Date: 2012-02-15.00:00:00

Proposed resolution (February, 2012):

  1. Change 15.2 [cpp.cond] paragraph 2 as follows:

  2. Each preprocessing token that remains (in the list of preprocessing tokens that will become the controlling expression) after all macro replacements have occurred shall be in the lexical form of a token (5.6 [lex.token]). Any such token that is a literal (5.13.1 [lex.literal.kinds]) shall be an integer-literal, a character-literal, or a boolean-literal.
  3. Change 15.2 [cpp.cond] paragraph 4 as follows:

  4. ...using arithmetic that has at least the ranges specified in 17.3 [support.limits]. The only operators permitted in the controlling constant expression are ?:, ||, &&, |, ^, &, ==, !=, <, <=, >, >=, <<, >>, -, +, *, /, %, !, and ~. For the purposes of this token conversion...
Date: 2012-01-02.00:00:00

It appears that some of the recent changes to the description of constant expressions have allowed constructs into preprocessor expressions that do not belong there. Some changes are required to restrict the current capabilities of constant expressions to what is intended to be allowed in preprocessor expressions.

History
Date User Action Args
2022-11-20 07:54:16adminsetmessages: + msg7034
2022-08-27 07:14:29adminsetstatus: drafting -> open
2022-03-30 18:46:38adminsetmessages: + msg6782
2012-11-03 00:00:00adminsetstatus: review -> drafting
2012-02-27 00:00:00adminsetmessages: + msg3763
2012-02-27 00:00:00adminsetstatus: open -> review
2012-01-02 00:00:00admincreate