[clang] [clang] Fixed Constant Evaluation don't Call Destructor (PR #140278)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 3 08:50:02 PDT 2025
================
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -std=c++23 -fsyntax-only %s -verify
+// RUN: %clang_cc1 -std=c++23 -fsyntax-only %s -verify -fexperimental-new-constant-interpreter
+
+namespace GH139818{
+ struct A {
+ constexpr ~A() { ref = false; }
+ constexpr operator bool() {
+ return b;
+ }
+ bool b;
+ bool& ref;
+ };
+
+ constexpr bool f1() {
+ bool ret = true;
+ for (bool b = false; A x{b, ret}; b = true) {}
+ return ret;
+ }
+
+ static_assert(!f1());
+
+ struct Y {
+ constexpr ~Y() noexcept(false) { throw "oops"; } // expected-error {{cannot use 'throw' with exceptions disabled}}
----------------
Mr-Anyone wrote:
I think I have updated it, thanks.
https://github.com/llvm/llvm-project/pull/140278
More information about the cfe-commits
mailing list