aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/constexpr.c4
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/constexpr-new21.C17
2 files changed, 19 insertions, 2 deletions
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 45adbab..7772fe6 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -865,7 +865,7 @@ maybe_save_constexpr_fundef (tree fun)
if (processing_template_decl
|| !DECL_DECLARED_CONSTEXPR_P (fun)
|| cp_function_chain->invalid_constexpr
- || DECL_CLONED_FUNCTION_P (fun))
+ || (DECL_CLONED_FUNCTION_P (fun) && !DECL_DELETING_DESTRUCTOR_P (fun)))
return;
if (!is_valid_constexpr_fn (fun, !DECL_GENERATED_P (fun)))
@@ -2372,7 +2372,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
*non_constant_p = true;
return t;
}
- if (DECL_CLONED_FUNCTION_P (fun))
+ if (DECL_CLONED_FUNCTION_P (fun) && !DECL_DELETING_DESTRUCTOR_P (fun))
fun = DECL_CLONED_FUNCTION (fun);
if (is_ubsan_builtin_p (fun))
diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-new21.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-new21.C
new file mode 100644
index 0000000..8231e99
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-new21.C
@@ -0,0 +1,17 @@
+// PR c++/100495
+// { dg-do compile { target c++20 } }
+
+struct S {
+ constexpr virtual ~S () {}
+};
+
+constexpr bool
+foo ()
+{
+ S *p = new S ();
+ delete p;
+ return true;
+}
+
+constexpr bool x = foo ();
+static_assert (x);