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

Re: [PATCH] 3.0: require C99 flexible-array member syntax

From
Patrick Steinhardt <ps@pks.im>
Date
Dec 12, 2025, 08:36 UTC
Message-ID
<aTvT8A31tQFvCvtL@pks.im>
In-Reply-To
<xmqqbjk5e32q.fsf@gitster.g>
On Thu, Dec 11, 2025 at 07:16:13PM +0900, Junio C Hamano wrote:
Show 21 quoted lines
> Before C99 syntax to express that the final member in a struct is an
> array of unknown number of elements, i.e.,
> 
> 	struct {
> 		...
> 		T flexible_array[];
> 	};
> 
> came along, GNU introduced their own extension to declare such a
> member with 0 size, i.e.,
> 
> 		T flexible_array[0];
> 
> and the compilers that did not understand even that were given a way
> to emulate it by wasting one element, i.e.,
> 
> 		T flexible_array[1];
> 
> As we are pushing more and more C99 language features, let's declare
> the historical forms of flexible array member support obsolete and
> require C99 syntax from all compilers that want to compile Git.

Is there any specific reason why this is tied to the 3.0 breaking changes document? I would have expected that we introduce this change via a test balloon like we usually do for new C features that we haven't used before. And we already are using C99 features, so I wouldn't consider this change to be "more breaking" than any of the other C99 features we have introduced already.

So I wonder whether we should instead convert one of the sites that currently uses FLEX_ARRAY to use C99 flexible arrays unconditionally. On the other hand we don't really gain much by doing that, as it is just as easy to adapt the FLEX_ARRAY definitions to unconditionally use C99 flexible arrays. Both would boil down to a couple lines of changes, only.

If we see that any platform out there doesn't support this feature we can still roll back and maybe tie it to Git 3.0.

Thanks!
Patrick
Previous: Junio C HamanoNext: Junio C Hamano
Message 2 of 3 in “3.0: require C99 flexible-array member syntax”
  1. 3.0: require C99 flexible-array member syntaxJunio C Hamano, Dec 11, 2025
  2. Patrick SteinhardtDec 12, 2025
  3. Junio C HamanoDec 12, 2025

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.