This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c/9058: structure with flexible array member: offsetof() != sizeof()
- From: Manfred Spraul <manfred at colorfullife dot com>
- To: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Cc: gcc-gnats at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org
- Date: Fri, 27 Dec 2002 00:37:54 +0100
- Subject: Re: c/9058: structure with flexible array member: offsetof() != sizeof()
- References: <Pine.LNX.4.33.0212262217270.4346-100000@kern.srcf.societies.cam.ac.uk>
Joseph S. Myers wrote:
On Thu, 26 Dec 2002, Manfred Spraul wrote:
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]);
You mean offsetof(struct a, c) + nr_entries * sizeof(short).
No, I meant what I wrote - is that valid? It would be less error prone,
e.g. if the type of the flexible array member is changed.
linux kernel, i.e gcc portability across platforms.
--
Manfred