public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/99281] internal compiler error: in assign_temp, at function.c:984
Date: Fri, 26 Feb 2021 07:38:18 +0000	[thread overview]
Message-ID: <bug-99281-4-qPjh2QHUis@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-99281-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99281

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-02-26

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  We're building a temporary of type X which we shouldn't do when
expanding

get<int> (&D.2164) [return slot optimization]

and we run into

#2  0x0000000000fd165a in expand_call (exp=<call_expr 0x7ffff66ed818>, 
    target=0x0, ignore=0) at /home/rguenther/src/gcc3/gcc/calls.c:3878
3873            else
3874              {
3875                /* For variable-sized objects, we must be called with a
target
3876                   specified.  If we were to allocate space on the stack
here,
3877                   we would have no way of knowing when to free it.  */
3878                rtx d = assign_temp (rettype, 1, 1);
3879                structure_value_addr = XEXP (d, 0);
3880                target = 0;

because target is NULL when we come via

#7  0x0000000001197afe in expand_assignment (to=<component_ref 0x7ffff66d9390>,
from=<call_expr 0x7ffff66ed818>, 
    nontemporal=false) at /home/rguenther/src/gcc3/gcc/expr.c:5482
5481              else
5482                result = store_field (to_rtx, bitsize, bitpos,
5483                                      bitregion_start, bitregion_end,
5484                                      mode1, from, get_alias_set (to),
5485                                      nontemporal, reversep);

and the large conditional on

  /* If the structure is in a register or if the component
     is a bit field, we cannot use addressing to access it.
     Use bit-field techniques or SUBREG to store in it.  */

somehow misfires on this, specifically there is

          /* And except for bitwise copying of TREE_ADDRESSABLE types,
             where the FIELD_DECL has the right bitsize, but TREE_TYPE (exp)
             includes some extra padding.  store_expr / expand_expr will in
             that case call get_inner_reference that will have the bitsize
             we check here and thus the block move will not clobber the
             padding that shouldn't be clobbered.  In the future we could
             replace the TREE_ADDRESSABLE check with a check that
             get_base_address needs to live in memory.  */
          && (!TREE_ADDRESSABLE (TREE_TYPE (exp))
              || TREE_CODE (exp) != COMPONENT_REF
              || !multiple_p (bitsize, BITS_PER_UNIT)
              || !multiple_p (bitpos, BITS_PER_UNIT)
              || !poly_int_tree_p (DECL_SIZE (TREE_OPERAND (exp, 1)),
                                   &decl_bitsize)
              || maybe_ne (decl_bitsize, bitsize)))

maybe sth as simple as the following works (instead of for return-slot-opt
we can also test !TREE_ADDRESSABLE here or boht for the testcase)

diff --git a/gcc/expr.c b/gcc/expr.c
index 86dc1b6c973..54007ac0efe 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -7214,7 +7214,10 @@ store_field (rtx target, poly_int64 bitsize, poly_int64
bitpos,
              || !multiple_p (bitpos, BITS_PER_UNIT)
              || !poly_int_tree_p (DECL_SIZE (TREE_OPERAND (exp, 1)),
                                   &decl_bitsize)
-             || maybe_ne (decl_bitsize, bitsize)))
+             || maybe_ne (decl_bitsize, bitsize))
+         /* A call with return-slot-opt must not need bitfield operations.  */
+         && (TREE_CODE (exp) != CALL_EXPR
+             || !CALL_EXPR_RETURN_SLOT_OPT (exp)))
       /* If we are expanding a MEM_REF of a non-BLKmode non-addressable
          decl we must use bitfield operations.  */
       || (known_size_p (bitsize)


note clang warns

t.ii:27:5: warning: expression result unused [-Wunused-value]
    pack_type<X>{get(1)};
    ^           ~~~~~~~~

  reply	other threads:[~2021-02-26  7:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-26  4:34 [Bug c++/99281] New: " jonathan.poelen at gmail dot com
2021-02-26  7:38 ` rguenth at gcc dot gnu.org [this message]
2021-02-26  8:51 ` [Bug c++/99281] " rguenth at gcc dot gnu.org
2021-02-26 11:34 ` cvs-commit at gcc dot gnu.org
2021-02-26 11:38 ` rguenth at gcc dot gnu.org
2024-04-05 23:01 ` pinskia at gcc dot gnu.org

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=bug-99281-4-qPjh2QHUis@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).