From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0096C3858D1E; Tue, 24 Jan 2023 18:27:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0096C3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674584825; bh=22sA67MCiYe90kQW3vHyOgPhU7ynKziJtRVas7Q2Z2U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=g4sZM2cDiVZjw3RGZEFbZYfivKdozPcntTH3QOGNbgxa4M3oPOsKL+H2pqQH8oWpX ehNYHqEr+wfph8ofwF2spMqBnl5YH6ytZrw7l99one6fk6C3NPJaIcjnS68l2u4c70 HZH4XcMd4ssJvQQmZglNdUfuprVDRUtetMDG3PVA= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/108522] [12/13 Regression] ICE in tree-object-size when struct has VLA Date: Tue, 24 Jan 2023 18:27:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: siddhesh at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc priority target_milestone 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=3D108522 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org Priority|P3 |P2 Target Milestone|--- |12.3 --- Comment #1 from Jakub Jelinek --- At least for backports one option can be punt (give the constant maximum or minimum) when variable length structures are involved, almost nobody uses t= hem (with the exception of Ada but then _FORTIFY_SOURCE=3D3 isn't on) and they = are quite a mess to support. Otherwise, one needs to make sure to use TREE_OPERAND (t, 2) of COMPONENT_R= EF if non-NULL. On the above testcase one can see: _3 =3D &s.1_9->b{off: _1}; _12 =3D __builtin_dynamic_object_size (_3, 1); That {off: _1} in there means COMPONENT_REF's last operand isn't NULL, but = is SSA_NAME _1. That contains something that should be used instead of DECL_FIELD_OFFSET if specified, because in DECL_FIELD_OFFSET you'll see a VAR_DECL that contained that value during gimplification, but isn't maintai= ned later on. tree-object-size.cc currently uses byte_position, which is ok if last COMPONENT_REF's operand is NULL, otherwise it should be byte_from_pos (TREE_OPERAND (component_ref, 2), DECL_FIELD_BIT_OFFSET (fiel= d)); where field is TREE_OPERAND (component_ref, 1).=