From: Alexandre Oliva <aoliva@redhat.com>
To: Jason Merrill <jason@redhat.com>
Cc: Christophe Lyon <christophe.lyon@linaro.org>,
gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: Re: [C++ Patch] [PR c++/88146] do not crash synthesizing inherited ctor(...)
Date: Fri, 28 Dec 2018 22:53:00 -0000 [thread overview]
Message-ID: <orsgyhh251.fsf@lxoliva.fsfla.org> (raw)
In-Reply-To: <d08703a7-71b7-6d06-54bb-d84c3dad7a64@redhat.com> (Jason Merrill's message of "Thu, 20 Dec 2018 11:09:18 -0500")
On Dec 20, 2018, Jason Merrill <jason@redhat.com> wrote:
> I think the bug is in calling instantiate_constexpr_fns in this case.
> I think that should only happen when ctx->manifestly_const_eval.
FTR, changing that breaks cpp2a/constexpr-init1.C (P0859),
unfortunately. I don't see why the operand of decltype or of int{}
would be manifestly const eval. Plus, I don't quite follow why the two
cases covered in the constexpr-init1.C testcase have different
consequences, constexpr-wise, even after rereading the verbiage about it
in the standard development tree a few times; I guess I still need to
fill in other gaps to in my knowledge to try and make sense of it.
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index cea414d33def..88bee7aa1fed 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -5076,7 +5076,8 @@ cxx_eval_outermost_constant_expr (tree t, bool allow_non_constant,
r = TARGET_EXPR_INITIAL (r);
}
- instantiate_constexpr_fns (r);
+ if (ctx.manifestly_const_eval)
+ instantiate_constexpr_fns (r);
r = cxx_eval_constant_expression (&ctx, r,
false, &non_constant_p, &overflow_p);
But, really, should varying but user-invisible cdtor return types really
ever play a role in determining whether a program is well-formed, like
they do ATM? I mean, is my suggested change wrong or undesirable for
some reason I can't grasp, aside from its incorrect implementation,
using operand0 of CALL_EXPR instead of operand0 of the ADDR_EXPR that
will be operand1 of CALL_EXPR if it's not NULL?
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index f758f2d9bc8f..9b3b4d039a16 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -1118,7 +1118,8 @@ convert_to_void (tree expr, impl_conv_void implicit, tsubst_flags_t complain)
error_at (loc, "pseudo-destructor is not called");
return error_mark_node;
}
- if (VOID_TYPE_P (TREE_TYPE (expr)))
+ if (VOID_TYPE_P (TREE_TYPE (expr))
+ && TREE_CODE (expr) != CALL_EXPR)
return expr;
switch (TREE_CODE (expr))
{
@@ -1175,6 +1176,26 @@ convert_to_void (tree expr, impl_conv_void implicit, tsubst_flags_t complain)
break;
case CALL_EXPR: /* We have a special meaning for volatile void fn(). */
+ /* cdtors may return this or void, depending on
+ targetm.cxx.cdtor_returns_this, but this shouldn't affect our
+ decisions here: nodiscard cdtors are nonsensical, and we
+ don't want to call maybe_warn_nodiscard because it may
+ trigger constexpr or template instantiation in a way that
+ changes their instantiaton nesting. This changes the way
+ contexts are printed in diagnostics, with bad consequences
+ for the testsuite, but there may be other undesirable
+ consequences of visiting referenced ctors too soon. */
+ if (TREE_OPERAND (expr, 1)
+ && TREE_CODE (TREE_OPERAND (expr, 1)) == ADDR_EXPR
+ && DECL_P (TREE_OPERAND (TREE_OPERAND (expr, 1), 0))
+ && IDENTIFIER_CDTOR_P (DECL_NAME (TREE_OPERAND (TREE_OPERAND (expr, 1), 0))))
+ return expr;
+ /* FIXME: Move this test before the one above, after a round of
+ testing as it is, to get coverage of the behavior we'd get on
+ ARM. */
+ else if (VOID_TYPE_P (TREE_TYPE (expr)))
+ return expr;
+
maybe_warn_nodiscard (expr, implicit);
break;
--
Alexandre Oliva, freedom fighter https://FSFLA.org/blogs/lxo
Be the change, be Free! FSF Latin America board member
GNU Toolchain Engineer Free Software Evangelist
Hay que enGNUrecerse, pero sin perder la terGNUra jamás-GNUChe
next prev parent reply other threads:[~2018-12-28 19:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-07 0:23 Alexandre Oliva
2018-12-14 20:14 ` Alexandre Oliva
2018-12-14 20:42 ` Jason Merrill
2018-12-14 21:41 ` Jason Merrill
2018-12-14 22:34 ` Alexandre Oliva
2018-12-14 22:44 ` Jason Merrill
2018-12-14 23:05 ` Alexandre Oliva
2018-12-15 22:11 ` Jason Merrill
2018-12-19 14:36 ` Christophe Lyon
2018-12-19 18:49 ` Alexandre Oliva
2018-12-19 18:52 ` Jakub Jelinek
2018-12-20 0:04 ` Alexandre Oliva
2018-12-20 16:00 ` Christophe Lyon
2018-12-20 16:18 ` Jason Merrill
2018-12-28 22:53 ` Alexandre Oliva [this message]
2018-12-29 6:40 ` Alexandre Oliva
2018-12-29 13:33 ` Jakub Jelinek
2019-01-04 18:55 ` Jason Merrill
2019-01-17 4:12 ` Alexandre Oliva
2018-12-29 10:28 ` Alexandre Oliva
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=orsgyhh251.fsf@lxoliva.fsfla.org \
--to=aoliva@redhat.com \
--cc=christophe.lyon@linaro.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).