llvm / llvm/llvm-project

Object parameters are considered to correspond depending on the order of declarations

Open
#189,525 3 comments 0 reactions 0 assignees View on GitHub
c++23 clang:frontend
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Consider the following example (https://godbolt.org/z/6GvM438PM):
```cpp
struct D {
void f1(this D) {}
void f1(this D&) {} // rejected

void f2(this D&) {}
void f2(this D) {} // accepted

void g1(this D) {}
void g1() & {} // rejected

void g2() & {}
void g2(this D) {} // accepted
};
```
Similar to #187686, the order of declarations matters, even though it's not supposed to.
Note that well-formedness of all 4 examples is under consideration by P4138 that discusses CWG3103.
CC @cor3ntin

Contributor guide

Open the contributing guide

Research direction

Reproduce the declaration-order differences in the linked Godbolt example, then compare the behavior with #187686 and the proposed treatment in P4138 and CWG3103. Trace the compiler's handling of object parameters and ref-qualified members; done means equivalent declarations receive consistent results regardless of declaration order, subject to the standard resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.