From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 851FE3836017; Wed, 28 Jul 2021 02:30:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 851FE3836017 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/54319] [9/10/11/12 Regression] empty class causes error while non-empty does not Date: Wed, 28 Jul 2021 02:30:12 +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: 4.7.1 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia 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: 9.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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: Wed, 28 Jul 2021 02:30:12 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D54319 --- Comment #10 from Andrew Pinski --- It is the code in call.c that makes a difference: if (is_really_empty_class (type, /*ignore_vptr*/true)) { /* Avoid copying empty classes. */ val =3D build2 (COMPOUND_EXPR, type, arg, to); suppress_warning (val, OPT_Wunused); } else if (tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (as_base))) { if (is_std_init_list (type) && conv_binds_ref_to_prvalue (convs[1])) warning_at (loc, OPT_Winit_list_lifetime, "assignment from temporary % doe= s " "not extend the lifetime of the underlying array"); arg =3D cp_build_fold_indirect_ref (arg); val =3D build2 (MODIFY_EXPR, TREE_TYPE (to), to, arg); } else { /* We must only copy the non-tail padding parts. */ tree arg0, arg2, t; tree array_type, alias_set; arg2 =3D TYPE_SIZE_UNIT (as_base); to =3D cp_stabilize_reference (to); arg0 =3D cp_build_addr_expr (to, complain); array_type =3D build_array_type (unsigned_char_type_node, build_index_type (size_binop (MINUS_EXPR, arg2, size_int (1))= )); alias_set =3D build_int_cst (build_pointer_type (type), 0); t =3D build2 (MODIFY_EXPR, void_type_node, build2 (MEM_REF, array_type, arg0, alias_set), build2 (MEM_REF, array_type, arg, alias_set)); val =3D build2 (COMPOUND_EXPR, TREE_TYPE (to), t, to); suppress_warning (val, OPT_Wunused); } if we do the middle one only, we get the correct type. I won't be able to debug this any further. But I suspect because we are lowering the AST too early, we don't do the correct type dealing here due to the COMPOUND_EXPR.=