[PATCH] D147591: [clang][Interp] Handle CXXTemporaryObjectExprs

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 5 10:54:25 PDT 2023


aaron.ballman added inline comments.


================
Comment at: clang/test/AST/Interp/records.cpp:317-318
     {
-      auto T = Test(Arr, Pos);
+      Test(Arr, Pos);
       // End of scope, should destroy Test.
     }
----------------
Nit: nothing actually tests that this object is destroyed correctly. Here's an interesting test to consider:
```
struct S {
  constexpr S() {}
  constexpr ~S() noexcept(false) { throw 12; }
};

constexpr int f() {
  S{};
  return 12;
}

static_assert(f() == 12);
```
That should fail because `~S()` would hit the `throw` expression and thus is not valid. Note, you'll need to add `-Wno-invalid-constexpr` to your test to avoid the warning-defaults-to-error about the destructor never producing a constant expression.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147591



More information about the cfe-commits mailing list