From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30618 invoked by alias); 26 Dec 2002 21:46:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 30604 invoked by uid 71); 26 Dec 2002 21:46:01 -0000 Date: Thu, 26 Dec 2002 13:46:00 -0000 Message-ID: <20021226214601.30603.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Manfred Spraul Subject: Re: c/9058: structure with flexible array member: offsetof() != sizeof() Reply-To: Manfred Spraul X-SW-Source: 2002-12/txt/msg01301.txt.bz2 List-Id: The following reply was made to PR c/9058; it has been noted by GNATS. From: Manfred Spraul To: "Joseph S. Myers" Cc: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org Subject: Re: c/9058: structure with flexible array member: offsetof() != sizeof() Date: Thu, 26 Dec 2002 22:45:04 +0100 Joseph S. Myers wrote: >On 26 Dec 2002 manfred@colorfullife.com wrote: > > > >>Now sizeof(struct x) is 8, offsetof(struct x, c) is 6. That seems to >>contradice the C99 standard: section 6.7.2.1, constraint 16. >> >> > >Please read the suggested TC in response to DR 282. (See N983 > and the Santa Cruz >minutes - the DR >log hasn't yet been updated.) > Thanks, I found the thread "C99 conformance bug in gcc-3.1" after filing the bug report. What's the recommended approach to calculate the size for malloc calls? Is struct a {int a; char b; short c[]; }; len = offsetof(struct a, c[nr_entries]); valid and portable? sizeof(struct a)+nr_entries*sizeof(short); would waste 2 bytes. -- Manfred