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

Alejandro Colomar
2022-11-12T17:09:14Z

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

On 11/12/22 18:02, Joseph Myers wrote:
> On Sat, 12 Nov 2022, Alejandro Colomar via Gcc wrote:
>
>>>> No, assigning to a function parameter from within another parameter
>>>> declaration wouldn't make sense. They should be readonly. Side effects
>>>> should be forbidden, I think.
>>>
>>> Such assignments are already allowed. In a function definition, the side
>>> effects (including in size expressions for array parameters adjusted to
>>> pointers) take place before entry to the function body.
>>
>> Then, I'm guessing that rules need to change in a way that .initializer cannot
>> appear as the left operand of an assignment-expression.
>
> I think needing such a very special case rule tends to indicate that some
> alternative syntax, not needing such a rule, would be better.

Well, by not being an lvalue, it can't be assigned to. That would be somewhat
like sizeof(identifier), which is also a unary-expression, so it's not so much
of a special case, is it?

void f(size_t s, int a[sizeof(1) = 1]); // constraint violation
void g(size_t s, int a[.s = 1]); // Also constraint violation
void h(size_t s, int a[s = 1]); // This is fine