On 7/12/23 10:10, Ng YongXiang via Gcc-patches wrote:
Component:
c++
Bug ID:
110057
Bugzilla link:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110057
Description:
Array should not call virtual destructor of object when array is destructed
ChangeLog:
2023-07-12 Ng YongXiang <yongxian...@gmail.com> PR c++
* Devirtualize auto generated destructor calls of arraycp/ *
init.c: Call non virtual destructor of objects in arraytestsuite/
* g++.dg/devirt-array-destructor-1.C: New. *
g++.dg/devirt-array-destructor-2.C: New.
On Wed, Jul 12, 2023 at 5:02 PM Xi Ruoyao <xry...@xry111.site> wrote:
On Wed, 2023-07-12 at 16:58 +0800, Ng YongXiang via Gcc-patches wrote:
I'm writing to seek for a review for an issue I filed some time ago.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110057 . A proposed patch
is
attached in the bug tracker as well.
You should send the patch to gcc-patches@gcc.gnu.org for a review, see
https://gcc.gnu.org/contribute.html for the details. Generally we
consider patches attached in bugzilla as drafts.
Thanks! The change makes sense under
https://eel.is/c++draft/expr.delete#3.sentence-2 , but please look again
at contribute.html.
In particular, the Legal section; you don't seem to have a copyright
assignment with the FSF, nor do I see a DCO certification
(https://gcc.gnu.org/dco.html) in your patch.
Like the examples in contribute.html, the subject line should be more
like "[PATCH] c++: devirtualization of array destruction [PR110057]"
The ChangeLog entry should be in the commit message.
* g++.dg/warn/pr83054.C: Change expected number of devirtualized calls
This isn't just changing the expected number, it's also changing the
array from a local variable to dynamically allocated, which is a big
change to what's being tested. If you want to test the dynamic case,
please add a new test instead of making this change.
diff --git a/gcc/testsuite/g++.dg/warn/pr83054.C
b/gcc/testsuite/g++.dg/warn/pr83054.C
index 5285f94acee..7cd0951713d 100644
--- a/gcc/testsuite/g++.dg/warn/pr83054.C
+++ b/gcc/testsuite/g++.dg/warn/pr83054.C
@@ -10,7 +10,7 @@
#endif
extern "C" int printf (const char *, ...);
-struct foo // { dg-warning "final would enable devirtualization of 5 calls" }
+struct foo // { dg-warning "final would enable devirtualization of 1 call" }
{
static int count;
void print (int i, int j) { printf ("foo[%d][%d] = %d\n", i, j, x); }
@@ -29,19 +29,15 @@ int foo::count;
int main ()
{
- {
- foo array[3][3];
- for (int i = 0; i < 3; i++)
- {
- for (int j = 0; j < 3; j++)
- {
- printf("&a[%d][%d] = %x\n", i, j, (void *)&array[i][j]);
- }
- }
- // The count should be nine, if not, fail the test.
- if (foo::count != 9)
- return 1;
- }
+ foo* arr[9];
+ for (int i = 0; i < 9; ++i)
+ arr[i] = new foo();
+ if (foo::count != 9)
+ return 1;
+ for (int i = 0; i < 9; ++i)
+ arr[i]->print(i / 3, i % 3);
+ for (int i = 0; i < 9; ++i)
+ delete arr[i];