git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: René Scharfe
Message 5 of 5 in “correct FLEXPTR_* example in comment”
  1. correct FLEXPTR_* example in commentRené Scharfe, Aug 13, 2016
  2. Jeff KingAug 13, 2016
  3. René ScharfeAug 13, 2016
  4. René ScharfeAug 13, 2016
  5. Jeff KingAug 13, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.