Re: [PATCH] correct FLEXPTR_* example in comment
- From
Jeff King <peff@peff.net>
- Date
- Aug 13, 2016, 18:36 UTC
- Message-ID
- <20160813183640.axpnjj44bteraevi@sigill.intra.peff.net>
- In-Reply-To
- <57AF582A.3050406@web.de>
On Sat, Aug 13, 2016 at 07:26:02PM +0200, René Scharfe wrote:
Show 12 quoted lines
> > I suppose it could assert(sizeof((x)->flexname) == FLEX_ALLOC) or > > something, but I'm not sure if it is worth worrying about. > > You can't use sizeof with an actual flexible array. It only works if > FLEX_ARRAY is defined as 1 (for platforms without native support), and > perhaps also if it's 0. > > offsetof(struct x, arr) == sizeof(struct x) won't work either because of > padding. > > I have no idea what you can do with a flexible array that would throw a > compile error when done with a pointer.
Thanks for the input. I'd say we should not worry about it. The reason this particular "bug" persisted is because it was in a comment. People tend to notice code that cannot possibly do anything but segfault before they even send in patches.
-Peff