Title
Trailing comma following enumerator-list
Status
cd1
Section
9.7.1 [dcl.enum]
Submitter
Charles Bryant

Created on 2005-05-10.00:00:00 last changed 161 months ago

Messages

Date: 2006-04-15.00:00:00

[Voted into WP at April, 2006 meeting.]

Date: 2005-10-15.00:00:00

Proposed resolution (October, 2005):

Change the grammar in 9.7.1 [dcl.enum] paragraph 1 as indicated:

enum-specifier:
    enum identifieropt { enumerator-listopt }
    enum identifieropt { enumerator-list , }
Date: 2005-05-10.00:00:00

The C language (since C99), and some C++ compilers, accept:

    enum { FOO, };

as syntactically valid. It would be useful

  • for machine generated code

  • for minimising changes when editing

  • to allow a distinction between the final item being intended as an ordinary item or as a limit:

  •   enum { red, green, blue, num_colours };  // note no comma
      enum { fred, jim, sheila, };             // last is not special
    

This proposed change is to permit a trailing comma in enum by adding:

enum identifieropt { enumerator-list , }

as an alternative definition for the enum-specifier nonterminal in 9.7.1 [dcl.enum] paragraph 1.

History
Date User Action Args
2008-10-05 00:00:00adminsetstatus: wp -> cd1
2006-11-05 00:00:00adminsetstatus: dr -> wp
2006-04-22 00:00:00adminsetmessages: + msg1364
2006-04-22 00:00:00adminsetstatus: ready -> dr
2005-10-22 00:00:00adminsetmessages: + msg1220
2005-10-22 00:00:00adminsetstatus: open -> ready
2005-05-10 00:00:00admincreate