Submitter: Jens Gustedt
Submission Date:
2012-10-08
Source: WG14
Reference Document:
N1647
Version: 1.0
Date: October 2012
Subject: sytax error in specification of for-statement
Summary
The standard lists two different forms for
the for
-statement in 6.8.5p1:
for ( expression[opt] ; expression[opt] ; expression[opt] ) statement for ( declaration expression[opt] ; expression[opt] ) statement
whereas later in 6.8.5.3 these two forms are subsumed in a third form by:
for ( clause-1 ; expression-2 ; expression-3 ) statement
Obviously the second form above is a typo and doesn't fit within this third form, the semantic that is given in 6.8.5.3 and to common practice in existing compilers.
Suggested Technical Corrigendum
Replace the second form in 6.8.5p1 and A.2.3 by the intended one:
for ( declaration expression[opt] ; expression[opt] ; expression[opt] ) statement
Proposed Committee Response
The second form of for-statement is not a typo. The syntax for "declaration", in 6.7 paragraph 1, includes an optional init-declarator-list and a trailing semicolon.