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

From: Patrick Steinhardt <[email-masked]>
Date: Fri, 12 Dec 2025 09:36:00 +0100

On Thu, Dec 11, 2025 at 07:16:13PM +0900, Junio C Hamano wrote:
> 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