aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2023-01-23 17:14:11 -0500
committerJason Merrill <jason@redhat.com>2023-01-23 18:35:11 -0500
commit4cbc71691e47b1ca6b64feb0af678606705d2f92 (patch)
treec3f5b175c0ad4ff4e3e7e7ac8574e254251e018f /gcc/cp
parent51767f31878a95161142254dca7119b409699670 (diff)
downloadgcc-4cbc71691e47b1ca6b64feb0af678606705d2f92.zip
gcc-4cbc71691e47b1ca6b64feb0af678606705d2f92.tar.gz
gcc-4cbc71691e47b1ca6b64feb0af678606705d2f92.tar.bz2
c++: TARGET_EXPR_ELIDING_P and std::move [PR107267]
With -ffold-simple-inlines, we turn calls to std::move into the static_cast equivalent. In this testcase, this exposes the FindResult temporary to copy elision which is not specified by the standard, through an optimization in gimplify_modify_expr_rhs. Since the type is not TREE_ADDRESSABLE, this is not detectable by the user, so we just need to soften the assert. PR c++/107267 gcc/cp/ChangeLog: * cp-gimplify.cc (cp_gimplify_init_expr): Allow unexpected elision of trivial types. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/move2.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/cp-gimplify.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc
index 340b464..83ba128 100644
--- a/gcc/cp/cp-gimplify.cc
+++ b/gcc/cp/cp-gimplify.cc
@@ -250,7 +250,10 @@ cp_gimplify_init_expr (tree *expr_p)
if (TREE_CODE (from) == TARGET_EXPR)
if (tree init = TARGET_EXPR_INITIAL (from))
{
- gcc_checking_assert (TARGET_EXPR_ELIDING_P (from));
+ /* Make sure that we expected to elide this temporary. But also allow
+ gimplify_modify_expr_rhs to elide temporaries of trivial type. */
+ gcc_checking_assert (TARGET_EXPR_ELIDING_P (from)
+ || !TREE_ADDRESSABLE (TREE_TYPE (from)));
if (target_expr_needs_replace (from))
{
/* If this was changed by cp_genericize_target_expr, we need to