From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1006B3858CDA; Wed, 16 Aug 2023 19:37:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1006B3858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692214620; bh=S/oh1L7Cma0uWmLiWhe2IqmulgQihlqkBZy1EUYdVxY=; h=From:To:Subject:Date:From; b=MViHxpUqvwFEcOP7tmW72cJZl6s43IeRVh8UsSYoloIRhT6YZV0bVpnF/zK464CTV SJ8fnjq88Ayof1DA0mIUbN/gMqawTXVH5z4AXmbqzkSP3N3gaE21UJW946/P9qdb95 a7S3OvEmlZhmA5689rhIB04VCi4FHQsdU7+GQlxE= From: "qinzhao at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/111040] New: __builtin_object_size: inconsistent result for subobject with member arrays. Date: Wed, 16 Aug 2023 19:36:59 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: qinzhao at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D111040 Bug ID: 111040 Summary: __builtin_object_size: inconsistent result for subobject with member arrays. Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: qinzhao at gcc dot gnu.org Target Milestone: --- __bos produces different results for subobject with different optimizations: #include #include #define noinline __attribute__((__noinline__)) struct fixed { size_t foo; char b; char array[10];=20 } q =3D {}; static void noinline bar () { struct fixed *p =3D &q; printf("the__bdos of max p->array sub is %d \n", __builtin_dynamic_object_size(p->array, 1));=20 return; } int main () { bar (); return 0; } when compiled with=20 /home/opc/Install/latest-d/bin/gcc -O -fstrict-flex-arrays=3D3 t.c ./a.out the__bdos of max p->array sub is 10=20 when compiled with (disable the early object size pass): /home/opc/Install/latest-d/bin/gcc -O -fstrict-flex-arrays=3D3 -fdisable-tree-early_objsz t.c ./a.out the__bdos of max p->array sub is 15=20 I assume that the correct result for __builtin_dynamic_object_size(p->array= , 1) should be 10.=