From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6E4983861823; Fri, 26 Feb 2021 07:38:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6E4983861823 From: "rguenth at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: keywords everconfirmed bug_status cf_reconfirmed_on Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Feb 2021 07:38:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99281 Richard Biener 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 --- Confirmed. We're building a temporary of type X which we shouldn't do when expanding get (&D.2164) [return slot optimization] and we run into #2 0x0000000000fd165a in expand_call (exp=3D,=20 target=3D0x0, ignore=3D0) 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 =3D assign_temp (rettype, 1, 1); 3879 structure_value_addr =3D XEXP (d, 0); 3880 target =3D 0; because target is NULL when we come via #7 0x0000000001197afe in expand_assignment (to=3D, from=3D,=20 nontemporal=3Dfalse) at /home/rguenther/src/gcc3/gcc/expr.c:5482 5481 else 5482 result =3D 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) !=3D 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_in= t64 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) !=3D 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{get(1)}; ^ ~~~~~~~~=