Re: [PATCH 16/21] __VA_OPT__: parsing
Dan Carpenter <[email protected]> Mon, 4 May 2026 14:56:34 +0300
| Newsgroups | org.kernel.vger.linux-sparse |
|---|---|
| Message-ID | <[email protected]> |
On Mon, Mar 16, 2026 at 07:04:10AM +0000, Al Viro wrote:
> +static struct token *parse_expansion(struct token *expansion, struct ident *name)
> +{
> + int slots = macro_nargs + (macro_vararg < 0);
> + struct arg_state args[slots] = {};
^^^^^^^^^^^^^^^^
Hi Al,
gcc-11 and gcc-12 don't allow variable length arrays with an initializer.
The compile fails with:
pre-process.c: In function ‘parse_expansion’:
pre-process.c:1513:16: error: variable-sized object may not be initialized
1513 | struct arg_state args[slots] = {};
| ^~~~~~~~~
make: *** [Makefile:263: pre-process.o] Error 1
make: *** Waiting for unfinished jobs....
It works in gcc-13 and later.
regards,
dan carpenter