From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4A06E3858D38; Wed, 25 Jan 2023 16:40:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A06E3858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674664814; bh=YJmPOthh39GVqMfcIKQHDJV1ud0eH6FGIo89oEBuXrs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=QxnxZuBrIUd0CQwuVsQqbzf4KhV5icYWjJRYXnIonhnXOr4jN7tnamCP2c2XRUxzs 6kXkZEvrs5iI+rQwxRNnj7gg2R8S7DUSf7QDiSMnp6LgiZeCXprLUJiGKA9/7PmPnU BjwI9NZ1jdKnlwqMudD6q/he0jJRpqed6xltT/+o= From: "qing.zhao at oracle dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107952] tree-object-size: inconsistent size for flexible arrays nested in structs Date: Wed, 25 Jan 2023 16:40:14 +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: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: qing.zhao at oracle dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: siddhesh at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107952 --- Comment #15 from Qing Zhao --- > On Jan 25, 2023, at 11:12 AM, siddhesh at gcc dot gnu.org wrote: >>=20 >>> The first is handled by the function just fine, >>=20 >> No, even the first case is not recognized by the current >> =E2=80=9Carray_ref_flexible_size_p=E2=80=9D, it=E2=80=99s not been ident= ified as a flexible array >> right now. >> Shall we include this case into =E2=80=9Carray_ref_flexible_size_p=E2=80= =9D? (It=E2=80=99s a GCC >> extension). >=20 > In the first case, array_ref_flexible_size_p recognizes S2.flex.data as h= aving > flexible size. The tests in my patch[1] for this bug checks for this. Oh, yes. That=E2=80=99s right. >=20 > However, array_ref_flexible_size_p does not recognize S2.flex as having > flexible size. It might make sense to support that, i.e. any struct or u= nion > with the last element as a flex array should be recognized as having flex= ible > size. Since S2.flex is not an =E2=80=9Carray_ref=E2=80=9D, it=E2=80=99s correct f= or array_ref_fleixble_size_p to return false for it, I think.=20 We might add a new utility routine to determine whether a ref to a struct or union have flexible array?=