]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Add testcase for DR 2728
authorJakub Jelinek <jakub@redhat.com>
Wed, 25 Sep 2024 14:07:11 +0000 (16:07 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 25 Sep 2024 14:26:35 +0000 (16:26 +0200)
Seems we already handle delete expressions the way the DR clarifies,
so this patch just adds a testcase which verifies that.

2024-09-25  Jakub Jelinek  <jakub@redhat.com>

* g++.dg/DRs/dr2728.C: New test.

gcc/testsuite/g++.dg/DRs/dr2728.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/DRs/dr2728.C b/gcc/testsuite/g++.dg/DRs/dr2728.C
new file mode 100644 (file)
index 0000000..3061b84
--- /dev/null
@@ -0,0 +1,20 @@
+// DR 2728 - Evaluation of conversions in a delete-expression
+// { dg-do run }
+
+struct S {
+  S (int *x) : p (x) {}
+  operator int * () const { ++s; return p; }
+  int *p;
+  static int s;
+};
+int S::s;
+
+int
+main ()
+{
+  int *a = new int;
+  S s (a);
+  delete s;
+  if (S::s != 1)
+    __builtin_abort ();
+}