From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0C0FA384DEE0; Tue, 5 Dec 2023 10:54:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0C0FA384DEE0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701773697; bh=JKYKdxLUAPk4yEuWR0lsAQQBOoZrk5C1bEltYhL/qCo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=MLYqYeAgajL1p/j0P4aRkTJ4BiowTGy1m89N35O8DR53l5wkcdbes84aHYOg+Xeet 9L0i053lOPBTyaYEjOc0OKeNAh92OKmTCdEHfjgrXaeS8DB19vy0y2zVmXLFgf/vM9 1jUxUv9sjhrTjS3vrnRQHynCuNIR7On2YtZkXVN4= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/112830] internal compiler error: in convert_memory_address_addr_space_1, at explow.cc:302 Date: Tue, 05 Dec 2023 10:54:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: addr-space, ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112830 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ebotcazou at gcc dot gnu.o= rg --- Comment #11 from Richard Biener --- I'm struggling in creating test coverage for the *VLA =3D {} gimplification= to memset. If I convince the C frontend to accept void bar (int n, __seg_fs void *p) { typedef struct { char t[n]; } T; *(__seg_fs T *)p =3D (T) {}; } with diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index df9a07928b5..a94270b6065 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -12223,12 +12223,7 @@ c_parser_postfix_expression_after_paren_type (c_pa= rser *parser, || (scspecs && scspecs->storage_class =3D=3D csc_static) || constexpr_p), constexpr_p, &richloc); type =3D groktypename (type_name, &type_expr, &type_expr_const); - if (type !=3D error_mark_node && C_TYPE_VARIABLE_SIZE (type)) - { - error_at (type_loc, "compound literal has variable size"); - type =3D error_mark_node; - } - else if (TREE_CODE (type) =3D=3D FUNCTION_TYPE) + if (TREE_CODE (type) =3D=3D FUNCTION_TYPE) { error_at (type_loc, "compound literal has function type"); type =3D error_mark_node; @@ -12257,6 +12252,13 @@ c_parser_postfix_expression_after_paren_type (c_pa= rser *parser, finish_init (); maybe_warn_string_init (type_loc, type, init); + if (type !=3D error_mark_node + && C_TYPE_VARIABLE_SIZE (type) + && CONSTRUCTOR_NELTS (init.value) !=3D 0) + { + error_at (type_loc, "compound literal has variable size"); + type =3D error_mark_node; + } if (type !=3D error_mark_node && !ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (type)) && current_function_decl) then I see the gimplifier fails to wrap the CONSTRUCTOR inside a WITH_SIZE_= EXPR which could be fixed with diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index a1d5ee28cbe..ae339c4a82a 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -5787,6 +5787,7 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, tree rhs =3D TREE_OPERAND (*expr_p, 1); if (want_value && object =3D=3D lhs) lhs =3D unshare_expr (lhs); + maybe_with_size_expr (&rhs); gassign *init =3D gimple_build_assign (lhs, rhs); gimplify_seq_add_stmt (pre_p, init); } diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc index a075fa38fba..e81b3f6ba72 100644 --- a/gcc/tree-cfg.cc +++ b/gcc/tree-cfg.cc @@ -3363,7 +3363,10 @@ verify_types_in_gimple_reference (tree expr, bool require_lvalue) } if (!require_lvalue - && (is_gimple_reg (expr) || is_gimple_min_invariant (expr))) + && (is_gimple_reg (expr) + || is_gimple_min_invariant (expr) + || (TREE_CODE (expr) =3D=3D CONSTRUCTOR + && CONSTRUCTOR_NELTS (expr) =3D=3D 0))) return false; if (TREE_CODE (expr) !=3D SSA_NAME && is_gimple_id (expr)) but then of course RTL expansion isn't prepared for this - we run into store_expr expanding the CTOR but it would require special-casing such RHS to eventually either call store_constructor or clear_storage_hints directly. Does Ada have support for address-spaces and is there a way to construct a testcase that requires clearing of a VLA object in another address-space?=