Title
Restrictions on nested statements within constexpr functions
Status
cd5
Section
9.2.6 [dcl.constexpr]
Submitter
Faisal Vali

Created on 2016-07-30.00:00:00 last changed 47 months ago

Messages

Date: 2018-11-15.00:00:00

Proposed resolution (November, 2018):

  1. Add the following two paragraphs after Clause 8 [stmt.stmt] paragraph 1:

  2. ...The optional attribute-specifier-seq appertains to the respective statement.

    A substatement of a statement is one of the following:

    • for a labeled-statement, its contained statement,

    • for a compound-statement, any statement of its statement-seq,

    • for a selection-statement, any of its statements (but not its init-statement), or

    • for an iteration-statement, its contained statement (but not an init-statement).

    [Note: The compound-statement of a lambda-expression is not a substatement of the statement (if any) in which the lambda-expression lexically appears. —end note]

    A statement S1 encloses a statement S2 if

    • S2 is a substatement of S1 (Clause 9 [dcl.dcl]),

    • S1 is a selection-statement or iteration-statement and S2 is the init-statement of S1,

    • S1 is a try-block and S2 is its compound-statement or any of the compound-statements of its handlers, or

    • S1 encloses a statement S3 and S3 encloses S2.

  3. Delete the following sentence from 8.5 [stmt.select] paragraph 1:

  4. In Clause 8 [stmt.stmt], the term substatement refers to the contained statement or statements that appear in the syntax notation.
  5. Change 9.2.6 [dcl.constexpr] bullet 3.3 as follows:

  6. The definition of a constexpr function shall satisfy the following requirements:

    • ...

    • its function-body shall be = delete, = default, or a compound-statement that does not contain enclose (Clause 8 [stmt.stmt]

      • ...

Date: 2019-02-15.00:00:00

[Accepted as a DR at the February, 2019 meeting.]

Section 9.2.6 [dcl.constexpr] bullet 3.4 specifies a list of constructs that that the body of a constexpr function shall not contain. However, the meaning of the word “contain” is not clear. For example, are things appearing in the body of a nested constexpr lambda “contained” in the body of the constexpr function?

History
Date User Action Args
2020-12-15 00:00:00adminsetmessages: + msg6393
2020-12-15 00:00:00adminsetstatus: drafting -> cd5
2016-07-30 00:00:00admincreate