This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c/9058: structure with flexible array member: offsetof() != sizeof()


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]