* C++ PATCH for c++/88825 - ICE with bogus function return type deduction
@ 2019-01-14 2:11 Marek Polacek
2019-01-14 20:06 ` Jason Merrill
0 siblings, 1 reply; 4+ messages in thread
From: Marek Polacek @ 2019-01-14 2:11 UTC (permalink / raw)
To: GCC Patches, Jason Merrill
In this (invalid) testcase the return type deduction failed so FUNCTYPE was
error_mark_node and can_do_nrvo_p crashed. One way to fix this would be to
check error_operand_p as below.
Bootstrapped/regtested on x86_64-linux, ok for trunk?
2019-01-13 Marek Polacek <polacek@redhat.com>
PR c++/88825 - ICE with bogus function return type deduction.
* typeck.c (can_do_nrvo_p): Check error_operand_p.
* g++.dg/cpp1y/auto-fn55.C: New test.
diff --git gcc/cp/typeck.c gcc/cp/typeck.c
index 43d2899a3c4..3d3049cc3a0 100644
--- gcc/cp/typeck.c
+++ gcc/cp/typeck.c
@@ -9342,6 +9342,8 @@ is_std_move_p (tree fn)
static bool
can_do_nrvo_p (tree retval, tree functype)
{
+ if (error_operand_p (functype))
+ return false;
if (retval)
STRIP_ANY_LOCATION_WRAPPER (retval);
tree result = DECL_RESULT (current_function_decl);
diff --git gcc/testsuite/g++.dg/cpp1y/auto-fn55.C gcc/testsuite/g++.dg/cpp1y/auto-fn55.C
new file mode 100644
index 00000000000..aea2740e1f5
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp1y/auto-fn55.C
@@ -0,0 +1,8 @@
+// PR c++/88825
+// { dg-do compile { target c++14 } }
+
+auto f () -> auto *
+{
+ int t = 0;
+ return t; // { dg-error "unable to deduce" }
+}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: C++ PATCH for c++/88825 - ICE with bogus function return type deduction
2019-01-14 2:11 C++ PATCH for c++/88825 - ICE with bogus function return type deduction Marek Polacek
@ 2019-01-14 20:06 ` Jason Merrill
2019-01-14 20:15 ` Marek Polacek
0 siblings, 1 reply; 4+ messages in thread
From: Jason Merrill @ 2019-01-14 20:06 UTC (permalink / raw)
To: Marek Polacek, GCC Patches
On 1/13/19 9:11 PM, Marek Polacek wrote:
> In this (invalid) testcase the return type deduction failed so FUNCTYPE was
> error_mark_node and can_do_nrvo_p crashed. One way to fix this would be to
> check error_operand_p as below.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>
> 2019-01-13 Marek Polacek <polacek@redhat.com>
>
> PR c++/88825 - ICE with bogus function return type deduction.
> * typeck.c (can_do_nrvo_p): Check error_operand_p.
error_operand_p also checks TREE_TYPE of its operand, is that useful
here instead of only comparing functype to error_mark_node?
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: C++ PATCH for c++/88825 - ICE with bogus function return type deduction
2019-01-14 20:06 ` Jason Merrill
@ 2019-01-14 20:15 ` Marek Polacek
2019-01-14 21:40 ` Jason Merrill
0 siblings, 1 reply; 4+ messages in thread
From: Marek Polacek @ 2019-01-14 20:15 UTC (permalink / raw)
To: Jason Merrill; +Cc: GCC Patches
On Mon, Jan 14, 2019 at 03:06:33PM -0500, Jason Merrill wrote:
> On 1/13/19 9:11 PM, Marek Polacek wrote:
> > In this (invalid) testcase the return type deduction failed so FUNCTYPE was
> > error_mark_node and can_do_nrvo_p crashed. One way to fix this would be to
> > check error_operand_p as below.
> >
> > Bootstrapped/regtested on x86_64-linux, ok for trunk?
> >
> > 2019-01-13 Marek Polacek <polacek@redhat.com>
> >
> > PR c++/88825 - ICE with bogus function return type deduction.
> > * typeck.c (can_do_nrvo_p): Check error_operand_p.
>
> error_operand_p also checks TREE_TYPE of its operand, is that useful here
> instead of only comparing functype to error_mark_node?
Actually, it isn't. So we can get away with a simple comparison, as in the
below:
Bootstrapped/regtested on x86_64-linux, ok for trunk?
2019-01-13 Marek Polacek <polacek@redhat.com>
PR c++/88825 - ICE with bogus function return type deduction.
* typeck.c (can_do_nrvo_p): Check error_mark_node.
* g++.dg/cpp1y/auto-fn55.C: New test.
diff --git gcc/cp/typeck.c gcc/cp/typeck.c
index 43d2899a3c4..3d3049cc3a0 100644
--- gcc/cp/typeck.c
+++ gcc/cp/typeck.c
@@ -9342,6 +9342,8 @@ is_std_move_p (tree fn)
static bool
can_do_nrvo_p (tree retval, tree functype)
{
+ if (functype == error_mark_node)
+ return false;
if (retval)
STRIP_ANY_LOCATION_WRAPPER (retval);
tree result = DECL_RESULT (current_function_decl);
diff --git gcc/testsuite/g++.dg/cpp1y/auto-fn55.C gcc/testsuite/g++.dg/cpp1y/auto-fn55.C
new file mode 100644
index 00000000000..aea2740e1f5
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp1y/auto-fn55.C
@@ -0,0 +1,8 @@
+// PR c++/88825
+// { dg-do compile { target c++14 } }
+
+auto f () -> auto *
+{
+ int t = 0;
+ return t; // { dg-error "unable to deduce" }
+}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: C++ PATCH for c++/88825 - ICE with bogus function return type deduction
2019-01-14 20:15 ` Marek Polacek
@ 2019-01-14 21:40 ` Jason Merrill
0 siblings, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2019-01-14 21:40 UTC (permalink / raw)
To: Marek Polacek; +Cc: GCC Patches
On 1/14/19 3:15 PM, Marek Polacek wrote:
> On Mon, Jan 14, 2019 at 03:06:33PM -0500, Jason Merrill wrote:
>> On 1/13/19 9:11 PM, Marek Polacek wrote:
>>> In this (invalid) testcase the return type deduction failed so FUNCTYPE was
>>> error_mark_node and can_do_nrvo_p crashed. One way to fix this would be to
>>> check error_operand_p as below.
>>>
>>> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>>>
>>> 2019-01-13 Marek Polacek <polacek@redhat.com>
>>>
>>> PR c++/88825 - ICE with bogus function return type deduction.
>>> * typeck.c (can_do_nrvo_p): Check error_operand_p.
>>
>> error_operand_p also checks TREE_TYPE of its operand, is that useful here
>> instead of only comparing functype to error_mark_node?
>
> Actually, it isn't. So we can get away with a simple comparison, as in the
> below:
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
OK.
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-01-14 21:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-14 2:11 C++ PATCH for c++/88825 - ICE with bogus function return type deduction Marek Polacek
2019-01-14 20:06 ` Jason Merrill
2019-01-14 20:15 ` Marek Polacek
2019-01-14 21:40 ` 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).