Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Missing ";" in the for statement Grammar

14 views
Skip to first unread message

Barry

unread,
Dec 31, 2007, 2:24:45 AM12/31/07
to
In ISO/IEC 14882:2003,
6.5/1

iteration-statement:
while ( condition ) statement
do statement while ( expression ) ;
for ( for-init-statement _;_ conditionopt ; expressionopt ) statement
^^^

I found out it remained repaired in N2369.

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std...@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]

Matti Rintala

unread,
Dec 31, 2007, 4:54:51 AM12/31/07
to
Barry wrote:
> In ISO/IEC 14882:2003,
> 6.5/1
>
> iteration-statement:
> while ( condition ) statement
> do statement while ( expression ) ;
> for ( for-init-statement _;_ conditionopt ; expressionopt ) statement

The semicolon is not missing, it is automatically included in the
for-init-statement (either an expression-statement or a simple-declaration,
both of which end in a semicolon). There is even a note explaining this in
6.5/1, both in 1998 and 2003 versions.

--
------------- Matti Rintala ------------ matti....@tut.fi ------------
Painting is the art of inclusion. Photography is an art of exclusion.

James Dennett

unread,
Dec 31, 2007, 10:33:53 AM12/31/07
to
Barry wrote:
> In ISO/IEC 14882:2003,
> 6.5/1
>
> iteration-statement:
> while ( condition ) statement
> do statement while ( expression ) ;
> for ( for-init-statement _;_ conditionopt ; expressionopt ) statement
> ^^^
>
> I found out it remained repaired in N2369.

>From memory, I believe that a for-init-statement always ends in a
semicolon and this "omission" is therefore deliberate.

-- James

0 new messages