From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9BBAC395C019; Fri, 20 Jan 2023 16:46:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9BBAC395C019 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674233176; bh=9yKUsyPhrZ7UvMS6bjBUQUN7M1JvQG2KV01C2h8dowg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kFcx8M8p9QoEF5SXUBfjbIU6ACPogLglZQyf/O+10twnVp3dc3Km/q98SQbHLl3zQ 8OiwxhA3lpezmNSNDuG7vZhDaHCsoH3AMawuh9VGWoAnU/DudYIMwfEW2ORrBPu2Ut UHQh7u5I+fVVk8RltFaqpUsANecvtiBec/OWxWJ4= From: "qinzhao at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/101832] __builtin_object_size(P->M, 1) where M ends with a flex-array behaves like sizeof() Date: Fri, 20 Jan 2023 16:46:14 +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: 12.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: qinzhao 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=3D101832 --- Comment #7 from qinzhao at gcc dot gnu.org --- from the standard: A structure or union shall not contain a member with incomplete or function type (hence, a structure shall not contain an instance of itself, but may contain a pointer to an instance of itself), except that the last member of= a structure with more than one named member may have incomplete array type; s= uch a structure (and any union containing, possibly recursively, a member that = is such a structure) shall not be a member of a structure or an element of an array. as a result, if you add -Wpedantic to the compilation line: [opc@qinzhao-ol8u3-x86 101832]$ sh t /home/opc/Install/latest-d/bin/gcc -O1 -Wpedantic t.c t.c:30:18: warning: invalid use of structure with flexible array member [-Wpedantic] 30 | struct nlmsg msg; | ^~~ However, looks like that GCC extension allow such usage, but I am not sure whether there is any documentation on such extension?=