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

Alejandro Colomar alx.manpages@gmail.com
Sat Nov 12 17:08:54 GMT 2022



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



-- 
<http://www.alejandro-colomar.es/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20221112/f9260725/attachment.sig>


More information about the Gcc mailing list