Title
Superfluous semicolons in class definitions
Status
c++14
Section
11.4 [class.mem]
Submitter
Richard Smith

Created on 2013-05-29.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: 2013-11-15.00:00:00

Proposed resolution (November, 2013):

  1. Change the grammar in 11.4 [class.mem] as follows:

    • member-declaration:
        attribute-specifier-seqopt decl-specifier-seqopt member-declarator-listopt ;
        function-definition ;opt
        using-declaration
        static_assert-declaration
        template-declaration
        alias-declaration
        empty-declaration
  2. Change 11.4 [class.mem] paragraph 1 as follows:

  3. ...Except when used to declare friends (11.8.4 [class.friend]) or to introduce the name of a member of a base class into a derived class (9.9 [namespace.udecl]), or when the declaration is an empty-declaration, member-declarations declare members of the class, and each such member-declaration shall declare at least one member name of the class.
Date: 2013-05-29.00:00:00

The grammar in 11.4 [class.mem] and 9.5.1 [dcl.fct.def.general] paragraph 1 are (in part):

    member-declaration:
      function-definition ;opt
    function-definition:
      function-body
    function-body:
      = default ;
      = delete ;

This leads to the following curiosity:

  struct A {
    void f1() = delete;   // #1, ok
    void f2() = delete;;  // #2, ok
    void f3() = delete;;; // #3, error, extraneous semicolon
  };

This could be addressed by moving the semicolon into the productions for function-body for the non-default/delete forms or by adding empty-declaration to the list of member-declaration productions, as is done with namespace-scope declarations.

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