[PATCH] D156244: [clang] Do not crash on use of a variadic overloaded operator
Mariya Podchishchaeva via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 28 07:04:44 PDT 2023
Fznamznon added inline comments.
================
Comment at: clang/test/SemaCXX/overloaded-operator-decl.cpp:64
+class E {};
+void operator+(E, ...) {} // expected-error{{overloaded 'operator+' cannot be variadic}}
+void d() { E() + E(); }
----------------
aaron.ballman wrote:
> I think it might make sense to extend the test coverage for the other operators you can overload, just to demonstrate we diagnose them all consistently. WDYT?
Okay, while trying to add more test cases I discovered that following
```
class E {};
bool operator<(const E& lhs, ...);
auto operator<=>(const E& lhs, ...);
void d() {
E() < E();
}
```
crashes even with the patch since there is code searching for best overload candidate that doesn't consider possibility for them making variadic.
The code around overloading is actually pretty inconsistent, somewhere invalid candidates are considered, and somewhere not, so I spent some time not knowing what to do.
I'm now inclined that we just shouldn't consider invalid candidates like @shafik
suggests. WDYY?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156244/new/
https://reviews.llvm.org/D156244
More information about the cfe-commits
mailing list