[PATCH] D136751: [clang][Interp] This pointers are writable in constructors

Shafik Yaghmour via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 16 19:18:58 PST 2023


shafik added inline comments.


================
Comment at: clang/lib/AST/Interp/Interp.cpp:264-270
+  const Function *Func = S.Current->getFunction();
+  if (Func && Func->isConstructor()) {
+    // The This pointer is writable in constructors, even if
+    // isConst() returns true.
+    if (Ptr.block() == S.Current->getThis().block())
+      return true;
+  }
----------------
tbaeder wrote:
> aaron.ballman wrote:
> > The same is true for destructors as well: https://godbolt.org/z/a49aEErz8
> Oh, good catch, thanks.
Interesting case: https://godbolt.org/z/5r5fdh9jr

Implementation divergence, have to figure out who is correct here.


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

https://reviews.llvm.org/D136751



More information about the cfe-commits mailing list