Spurious semicolons at namespace scope should be allowed
Clause [9] [dcl.dcl]
Matt Austern

Created on 2006-03-20.00:00:00 last changed 143 months ago


Date: 2009-03-15.00:00:00

[Voted into the WP at the March, 2009 meeting.]

Date: 2006-10-15.00:00:00

Proposed resolution (October, 2006):

  1. Add the indicated lines to the grammar definitions in Clause 9 [dcl.dcl] paragraph 1:

  2. declaration:


      static_assert ( constant-expression , string-literal ) ;

  3. Add the following as a new paragraph after Clause 9 [dcl.dcl] paragraph 4:

  4. An empty-declaration has no effect.
Date: 2020-12-15.00:00:00

The grammar in Clause 9 [dcl.dcl] paragraph 1 says that a declaration-seq is either declaration or declaration-seq declaration. Some declarations end with semicolons and others (e.g. function definitions and namespace declarations) don't. This means that users who put a semicolon after every declaration are technically writing ill-formed code. The trouble is that in this respect the standard is out of sync with reality. It's convenient to allow semicolons after every declaration, and there's no implementation difficulty in doing so. All existing compilers accept this, except in extra-pedantic mode. When all implementations disagree with the standard, it's time for the standard to change.

Suggested resolution:

In the grammar in Clause 9 [dcl.dcl] paragraph 11, change the second line in the definition of declaration-seq to

    declaration-seq ;opt declaration
Date User Action Args
2010-03-29 00:00:00adminsetstatus: wp -> cd2
2009-08-03 00:00:00adminsetstatus: dr -> wp
2009-03-23 00:00:00adminsetmessages: + msg2022
2009-03-23 00:00:00adminsetstatus: ready -> dr
2008-10-05 00:00:00adminsetstatus: review -> ready
2006-11-05 00:00:00adminsetmessages: + msg1405
2006-11-05 00:00:00adminsetstatus: open -> review
2006-03-20 00:00:00admincreate