This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-11-11


2537. Overbroad grammar for parameter-declaration

Section: 9.3.4.6  [dcl.fct]     Status: drafting     Submitter: Davis Herring     Date: 2021-02-25

9.3.4.6 [dcl.fct] paragraph 3 specifies the grammar for parameter-declaration:

  parameter-declaration:
      attribute-specifier-seqopt thisopt decl-specifier-seq declarator
      attribute-specifier-seqopt thisopt decl-specifier-seq declarator = initializer-clause
      attribute-specifier-seqopt thisopt decl-specifier-seq abstract-declaratoropt
      attribute-specifier-seqopt thisopt decl-specifier-seq abstract-declaratoropt = initializer-clause

This is overly permissive; using a defining-type-specifier-seq instead of a decl-specifier-seq is sufficient.

Proposed resolution (November, 2022):

  1. Change in 9.2.2 [dcl.stc] paragraph 4 as follows:

    There can be no static function declarations within a block, nor any static function parameters.
  2. Change in 9.2.2 [dcl.stc] paragraph 5 as follows:

    The extern specifier shall not be used in the declaration of a class member or function parameter.
  3. Change in 9.2.4 [dcl.typedef] paragraph 1 as follows:

    The typedef specifier shall not be combined in a decl-specifier-seq with any other kind of specifier except a defining-type-specifier, and it shall not be used in the decl-specifier-seq of a parameter-declaration (9.3.4.6 [dcl.fct]) nor in the decl-specifier-seq of a function-definition (9.5 [dcl.fct.def]).
  4. Change in 9.2.8 [dcl.inline] paragraph 4 as follows:

    The inline specifier shall not appear on a block scope declaration or on the declaration of a function parameter.
  5. Change in 9.3.4.6 [dcl.fct] paragraph 3 as follows:

      parameter-declaration:
          attribute-specifier-seqopt thisopt decl-specifier-seq defining-type-specifier-seq declarator
          attribute-specifier-seqopt thisopt decl-specifier-seq defining-type-specifier-seq declarator = initializer-clause
          attribute-specifier-seqopt thisopt decl-specifier-seq defining-type-specifier-seq abstract-declaratoropt
          attribute-specifier-seqopt thisopt decl-specifier-seq defining-type-specifier-seq abstract-declaratoropt = initializer-clause
    

CWG 2023-02-07

Additional drafting is needed to address references to decl-specifier-seq in other parts of the standard. A list is here. Furthermore, reducing the grammar to a type-specifier-seq appears to be sufficient.