CWG2846 [dcl.fct] Out-of-line definitions of explicit object member functions · Issue #493 · cplusplus/CWG (original) (raw)

Full name of submitter: Krystian Stasiowski

Reference (section label): [dcl.fct]

Link to reflector thread (if any): N/A

Issue description:

According to [dcl.fct] p6:

An explicit-object-parameter-declaration is a parameter-declaration with a this specifier. An explicit-object-parameter-declaration shall appear only as the first parameter-declaration of a parameter-declaration-list of either:

A member-declarator with an explicit-object-parameter-declaration shall not include a ref-qualifier or a cv-qualifier-seq and shall not be declared static or virtual.

In the following example:

struct A { void f(this A&); };

void A::f(this A&) { }

The out-of-line definition of A::f is not a member-declarator, therefore it cannot contain an explicit-object-parameter-declaration. However, this is accepted by clang, GCC, EDG, and MSVC.

Suggested resolution:

Replace the first subbullet of [dcl.fct] p6 with:

Change the final sentence of [dcl.fct] p6 as follows (note: this affects some of the wording touched by CWG2553:

A member-declaratornon-static member function with an explicit-object-parameter-declaration shall not include a ref-qualifier or a cv-qualifier-seq and shall not be declared static or virtual.