[clang] Use the correct namespace for looking up matching operator!= (PR #68922)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 13 13:15:22 PDT 2023


zygoloid wrote:

> > Does this work for function-scope operator declarations?
> 
> @zygoloid I am not sure I follow. Could you please give an example.

Sure:

```c++
struct X { operator int(); };

bool f(X x) {
  bool operator==(X, int);
  return x == x;
}


bool g(X x) {
  bool operator==(X, int);
  bool operator!=(X, int);
  return x == x;
}

bool operator!=(X, int);

bool h(X x) {
  bool operator==(X, int);
  return x == x;
}


bool i(X x) {
  bool operator==(X, int);
  bool operator!=(X, int);
  return x == x;
}
```

Based on the standard's rules, it looks like `f` and `g` should be invalid due to ambiguity, but `h` and `i` should be valid. (Which I think is a pretty surprising outcome, but that's what the rules say.)

If there's not already something like that in our test suite, it'd be good to add it.

https://github.com/llvm/llvm-project/pull/68922


More information about the cfe-commits mailing list