cplusplus / draft

C++ standards drafts
http://www.open-std.org/jtc1/sc22/wg21/
5.68k stars 749 forks source link

[dcl.type.general] p3 The grammar type-specifier-seq does not comprise defining-type-specifier #5540

Open xmh0511 opened 2 years ago

xmh0511 commented 2 years ago

[dcl.type.general] p3 says

Except in a declaration of a constructor, destructor, or conversion function, at least one defining-type-specifier that is not a cv-qualifier shall appear in a complete type-specifier-seq or a complete decl-specifier-seq.

The grammar type-specifier-seq is the sequence of type-specifier, which can never include a defining-type-specifier. A defining-type-specifier can be a type-specifer but not the way around; that is, defining-type-specifier is a wider component than type-specifer. As specified in https://stackoverflow.com/questions/62506440/why-a-conversion-function-declaration-does-not-require-at-least-one-defining-typ

The suggested resolution might be

Except the decl-specifier-seq in a declaration of a constructor, destructor, or conversion function, a complete decl-specifier-seq shall contain at least one defining-type-specifier that is not a cv-qualifier, and a complete type-specifier-seq shall contain at least one type-specifier that is not a cv-qualifier.

As a drive-by, the exception should only apply to the decl-specifier-seq of the conversion function, since the type-specifier-seq in its conversion-type-id should obey the rule; comprise at least a type-specifier that is not a cv-qualifier.

jensmaurer commented 2 years ago

The proposed amendment still misses a rule such as "A complete defining-type-specifier-seq shall contain at least one defining-type-specifier that is not a cv-qualifier."