* C++ PATCH to fix ICE with NSDMI and this pointer (PR c++/79796)
@ 2017-03-03 16:34 Marek Polacek
2017-03-06 16:30 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2017-03-03 16:34 UTC (permalink / raw)
To: GCC Patches, Jason Merrill
We weren't replacing PLACEHOLDER_EXPR in the following testcase, leading to a
crash in the gimplifier. The fix seems to be to use replace_placeholders, the
question is where. These three functions have it:
cp_gimplify_init_expr
store_init_value
build_new_1
But we call neither so I tried adding the call to build_over_call, right
after we create the MODIFY_EXPR with the NSDMI, and that seemed to work
out.
Bootstrapped/regtested on x86_64-linux, ok for trunk?
2017-03-03 Marek Polacek <polacek@redhat.com>
PR c++/79796 - ICE with NSDMI and this pointer
* call.c (build_over_call): Handle NSDMI with a 'this' by calling
replace_placeholders.
* g++.dg/cpp0x/nsdmi13.C: New test.
diff --git gcc/cp/call.c gcc/cp/call.c
index dc629b96..b821224 100644
--- gcc/cp/call.c
+++ gcc/cp/call.c
@@ -8047,6 +8047,9 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
{
arg = cp_build_indirect_ref (arg, RO_NULL, complain);
val = build2 (MODIFY_EXPR, TREE_TYPE (to), to, arg);
+ if (cxx_dialect >= cxx14)
+ /* Handle NSDMI that refer to the object being initialized. */
+ replace_placeholders (arg, to);
}
else
{
diff --git gcc/testsuite/g++.dg/cpp0x/nsdmi13.C gcc/testsuite/g++.dg/cpp0x/nsdmi13.C
index e69de29..2751da3 100644
--- gcc/testsuite/g++.dg/cpp0x/nsdmi13.C
+++ gcc/testsuite/g++.dg/cpp0x/nsdmi13.C
@@ -0,0 +1,13 @@
+// PR c++/79796
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+ A* p = this;
+};
+
+void foo()
+{
+ A a;
+ a = A({});
+}
Marek
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: C++ PATCH to fix ICE with NSDMI and this pointer (PR c++/79796)
2017-03-03 16:34 C++ PATCH to fix ICE with NSDMI and this pointer (PR c++/79796) Marek Polacek
@ 2017-03-06 16:30 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2017-03-06 16:30 UTC (permalink / raw)
To: Marek Polacek; +Cc: GCC Patches
OK.
On Fri, Mar 3, 2017 at 6:34 AM, Marek Polacek <polacek@redhat.com> wrote:
> We weren't replacing PLACEHOLDER_EXPR in the following testcase, leading to a
> crash in the gimplifier. The fix seems to be to use replace_placeholders, the
> question is where. These three functions have it:
> cp_gimplify_init_expr
> store_init_value
> build_new_1
> But we call neither so I tried adding the call to build_over_call, right
> after we create the MODIFY_EXPR with the NSDMI, and that seemed to work
> out.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>
> 2017-03-03 Marek Polacek <polacek@redhat.com>
>
> PR c++/79796 - ICE with NSDMI and this pointer
> * call.c (build_over_call): Handle NSDMI with a 'this' by calling
> replace_placeholders.
>
> * g++.dg/cpp0x/nsdmi13.C: New test.
>
> diff --git gcc/cp/call.c gcc/cp/call.c
> index dc629b96..b821224 100644
> --- gcc/cp/call.c
> +++ gcc/cp/call.c
> @@ -8047,6 +8047,9 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
> {
> arg = cp_build_indirect_ref (arg, RO_NULL, complain);
> val = build2 (MODIFY_EXPR, TREE_TYPE (to), to, arg);
> + if (cxx_dialect >= cxx14)
> + /* Handle NSDMI that refer to the object being initialized. */
> + replace_placeholders (arg, to);
> }
> else
> {
> diff --git gcc/testsuite/g++.dg/cpp0x/nsdmi13.C gcc/testsuite/g++.dg/cpp0x/nsdmi13.C
> index e69de29..2751da3 100644
> --- gcc/testsuite/g++.dg/cpp0x/nsdmi13.C
> +++ gcc/testsuite/g++.dg/cpp0x/nsdmi13.C
> @@ -0,0 +1,13 @@
> +// PR c++/79796
> +// { dg-do compile { target c++11 } }
> +
> +struct A
> +{
> + A* p = this;
> +};
> +
> +void foo()
> +{
> + A a;
> + a = A({});
> +}
>
> Marek
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-06 16:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-03 16:34 C++ PATCH to fix ICE with NSDMI and this pointer (PR c++/79796) Marek Polacek
2017-03-06 16:30 ` 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).