Title
Defining types in conditions and range-based for statements
Status
c++14
Section
8.5 [stmt.select]
Submitter
Richard Smith

Created on 2013-08-08.00:00:00 last changed 121 months ago

Messages

Date: 2014-02-15.00:00:00

[Moved to DR at the February, 2014 meeting.]

Date: 2014-01-15.00:00:00

Proposed resolution (January, 2014):

  1. Change 8.5 [stmt.select] paragraph 2 as follows:

  2. The rules for conditions apply both to selection-statements and to the for and while statements (8.6 [stmt.iter]). The declarator shall not specify a function or an array. The decl-specifier-seq shall not define a class or enumeration. If the auto type-specifier appears in the decl-specifier-seq, the type of the identifier being declared is deduced from the initializer as described in 9.2.9.7 [dcl.spec.auto].
  3. Change 8.6.5 [stmt.ranged] paragraph 2 as follows:

  4. In the decl-specifier-seq of a for-range-declaration, each decl-specifier shall be either a type-specifier or constexpr. The decl-specifier-seq shall not define a class or enumeration.
Date: 2013-08-08.00:00:00

The interaction of various issue resolutions has inadvertently resulted in the loss of the prohibition of defining types in conditions (8.5 [stmt.select] paragraph 1) and in a range-based for (8.6 [stmt.iter] paragraph 1). Issue 686 addressed a patchwork of restrictions by banning type definitions in type-specifier-seqs. Issue 948 then changed the definition of condition to use a decl-specifier-seq instead of a type-specifier-seq in order to permit the constexpr specifier. A similar change was made for range-based for statements by issue 1204.

The restrictions against type definitions in these contexts should be restored.

History
Date User Action Args
2014-11-24 00:00:00adminsetstatus: dr -> c++14
2014-03-03 00:00:00adminsetmessages: + msg4945
2014-03-03 00:00:00adminsetstatus: tentatively ready -> dr
2014-01-20 00:00:00adminsetmessages: + msg4725
2014-01-20 00:00:00adminsetstatus: drafting -> tentatively ready
2013-10-14 00:00:00adminsetstatus: open -> drafting
2013-08-08 00:00:00admincreate