[PATCH] D111817: Fix a rejects-valid with consteval on overloaded operators

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 14 10:27:59 PDT 2021


aaron.ballman added inline comments.


================
Comment at: clang/lib/Sema/SemaOverload.cpp:14290
 
     return MaybeBindToTemporary(call);
   }
----------------
erichkeane wrote:
> rsmith wrote:
> > aaron.ballman wrote:
> > > erichkeane wrote:
> > > > Was this one missed too?
> > > I couldn't devise a test case that was failing with member function call expressions, so I left this one alone. We have a bunch of existing test coverage for calling a consteval member function, so I'm assuming this is correct, but if someone finds a test case that fails here, it's easy enough to fix.
> > This code is only reachable for a call through a pointer-to-member. We don't need to worry about `consteval` member function pointers because they can't escape constant-evaluated contexts anyway. Eg, `(p->*&Class::consteval_fn)()` is ill-formed outside of a constant-evaluated context -- we should make sure we have a test for that.
> I can't come up with one either, I think we're fine for now.
```
struct test {
  consteval int f() const { return 12; }
};

constexpr test t;
int main() {
  constexpr int i = (t.*&test::f)();
}
```
@rsmith -- would you expect us to accept or reject this? GCC accepts, MSVC rejects, Clang currently rejects. This is different from your test case (because this is in a constant evaluated context), which we do already reject with a decent message: https://godbolt.org/z/3nv4bco9M


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111817/new/

https://reviews.llvm.org/D111817



More information about the cfe-commits mailing list