https://bugs.llvm.org/show_bug.cgi?id=44627

            Bug ID: 44627
           Summary: Reversed candidate operator is not found by argument
                    dependent lookup
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangb...@nondot.org
          Reporter: da...@doublewise.net
                CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
                    llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk

The following code

```
namespace n {

struct type {};

bool operator==(type lhs, int rhs) {
        return true;
}

} // namespace n

void f() {
    n::type() == 0;
    0 == n::type(); // fails
}
```

fails to compile with the error message

```
<source>:13:7: error: invalid operands to binary expression ('int' and
'n::type')

    0 == n::type(); // fails

    ~ ^  ~~~~~~~~~

<source>:5:6: note: candidate function not viable: no known conversion from
'int' to 'n::type' for 1st argument

bool operator==(type lhs, int rhs) {

     ^

1 error generated.

Compiler returned: 1
```

when compiled against clang trunk with `clang++ -std=c++2a -stdlib=libc++ -w`.
The same thing occurs for `<=>` and the other comparison operators. Note that
it succeeds if the definition of `f` is moved into `n`.

See it live: https://godbolt.org/z/pHwvw6

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to