[clang] [clang] Fixed Constant Evaluation don't Call Destructor (PR #140278)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 3 06:16:29 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}}
----------------
Sirraide wrote:
Can you add `-fcxx-exceptions` (I think that was the flag at least) to the `RUN` lines so we don’t get this error.
https://github.com/llvm/llvm-project/pull/140278
More information about the cfe-commits
mailing list