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
Consider:
struct S { void f() &; }; void S::f(this S&) {}
Both declarations of S::f correspond (6.4.1 [basic.scope.scope] paragraph 4), but are ill-formed according to 6.6 [basic.link] paragraph 1, because the functions are not of the same type:
For any two declarations of an entity E:
- If one declares E to be a variable or function, the other shall declare E as one of the same type.
- ...
A similar situation arises for the following example:
struct S { void g() &; }; void S::g() { }
Possible resolution:
Add a note in 6.4.1 [basic.scope.scope] paragraph 4 as follows:
[ Note: Two function declarations with different ref-qualifiers or parameter-type-lists do not have the same type even if they correspond (6.6 [basic.link]). -- end note ]
[ Example 2:typedef int Int; ... void m(); void n(); }; X::m() & {} // error: redeclaration of X::m with a different type X::n(this X&) {} // error: redeclaration of X::n with a different type