Re: [PATCH] Various pages: SYNOPSIS: Use VLA syntax in function parameters

Alejandro Colomar
2022-11-12T12:46:32Z

[-- Attachment #1.1: Type: text/plain, Size: 1004 bytes --]

On 11/12/22 13:34, Alejandro Colomar wrote:
> struct s {
>     int a;
> };
>
> struct t {
>     struct s s;
>     int a;
> };
>
> void f(void)
> {
>     struct t x = {
>         .a = 1,
>         .s = {
>             .a = ((struct s) {.a = 1}).a,
>         },
>     };
> }

From here, a demonstration of what I understood from Martin's email is that
there's also an idea of allowing the following:

struct s {
int a;
int b;
};

struct t {
struct s s;
int a;
int b;
};

void f(void)
{
struct t x = {
.a = 1,
.s = {
// In the following line, .b=.a is assigning 2
.a = ((struct s) {.a = 2, .b = .a}).b,
// The previous line assigned 2, since the compound had 2 in .b
},
// In the following line, .b=.a is assigning 1
.b = .a,
};
}