[clang] [clang-tools-extra] [clang][bytecode] Don't evaluate bound member function expressions in new constant interpreter (PR #194851)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 30 03:17:43 PDT 2026


================
@@ -2640,6 +2640,14 @@ bool Compiler<Emitter>::VisitMemberExpr(const MemberExpr *E) {
   }
 
   if (!isa<FieldDecl>(Member)) {
+    // Bound member functions (non-static CXXMethodDecls) cannot be
+    // constant-evaluated. visitDeclRef would blindly push a FnPtr,
+    // but the caller expects a MemberPointer, causing a stack mismatch.
+    if (const auto *MD = dyn_cast<CXXMethodDecl>(Member)) {
+      if (!MD->isStatic())
----------------
tbaederr wrote:

```suggestion
    if (const auto *MD = dyn_cast<CXXMethodDecl>(Member);
    MD && !MD->isStatic()) {
```

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


More information about the cfe-commits mailing list