public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-9985] c++: temp cleanup in new [PR105265]
@ 2022-05-12 20:14 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2022-05-12 20:14 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:728f97cf0431ff342beceea4f91afa1707133248
commit r11-9985-g728f97cf0431ff342beceea4f91afa1707133248
Author: Jason Merrill <jason@redhat.com>
Date: Wed Apr 13 20:18:33 2022 -0400
c++: temp cleanup in new [PR105265]
The patch for PR100838 in GCC 11 was limited to -fno-elide-constructors for
safety, but this testcase demonstrates that it's also needed without that
flag. So let's switch to the GCC 12 patch for PR100838.
PR c++/105265
PR c++/100838
gcc/cp/ChangeLog:
* call.c (build_user_type_conversion_1): Drop
flag_elide_constructors check.
(convert_like_internal): Likewise.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/initlist-new6.C: New test.
Diff:
---
gcc/cp/call.c | 8 +++---
gcc/testsuite/g++.dg/cpp0x/initlist-new6.C | 39 ++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 5 deletions(-)
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 023e5e0f4b5..46c2a066499 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -4128,7 +4128,8 @@ build_user_type_conversion_1 (tree totype, tree expr, int flags,
We represent this in the conversion sequence with an
rvalue conversion, which means a constructor call. */
if (!TYPE_REF_P (totype)
- && (flag_elide_constructors || (flags & LOOKUP_ONLYCONVERTING))
+ && cxx_dialect < cxx17
+ && (flags & LOOKUP_ONLYCONVERTING)
&& !(convflags & LOOKUP_NO_TEMP_BIND))
cand->second_conv
= build_conv (ck_rvalue, totype, cand->second_conv);
@@ -7815,13 +7816,10 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum,
break;
};
- tsubst_flags_t sub_complain = complain;
- if (!flag_elide_constructors)
- sub_complain &= ~tf_no_cleanup;
expr = convert_like (next_conversion (convs), expr, fn, argnum,
convs->kind == ck_ref_bind
? issue_conversion_warnings : false,
- c_cast_p, sub_complain);
+ c_cast_p, complain & ~tf_no_cleanup);
if (expr == error_mark_node)
return error_mark_node;
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-new6.C b/gcc/testsuite/g++.dg/cpp0x/initlist-new6.C
new file mode 100644
index 00000000000..0ef27806acf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-new6.C
@@ -0,0 +1,39 @@
+// PR c++/105265
+// { dg-do run { target c++11 } }
+
+int c;
+
+class Block
+{
+public:
+ Block(int n) : data{new char[n]}, size{n}
+ {
+ ++c;
+ }
+
+ ~Block()
+ {
+ --c;
+ delete[] data;
+ }
+
+private:
+ char* data;
+ int size;
+};
+
+struct Cargo
+{
+ Block const& block;
+};
+
+int main()
+{
+ {
+ Cargo* c = new Cargo{{4000}};
+ delete c;
+ }
+ if (c != 0)
+ __builtin_abort ();
+ return 0;
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-12 20:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12 20:14 [gcc r11-9985] c++: temp cleanup in new [PR105265] Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).