[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] regex: use C99-style array arg syntax
From: |
Bruno Haible |
Subject: |
Re: [PATCH] regex: use C99-style array arg syntax |
Date: |
Fri, 27 Aug 2021 11:56:46 +0200 |
Hi Paul,
Thanks for the explanations.
> any of the access modes 'read', 'write',
> 'read_write', 'none' are incorrect for some valid and reasonable regexec
> calls.
So, to make the __access__ attribute [1] really consistent, they would need to
add a fifth access-mode 'any', that would not restrict the access pattern.
> void g (int n, int a[n]) { }
> void h (int n, int a[static n]) { }
So, the 'g' syntax is a somewhat broken language feature, since the compiler
can use it for warnings but not for optimizations.
And the essential difference between 'g' and 'h' is that g accepts a NULL
argument, whereas 'h' doesn't.
How about this comment for _REGEX_NELTS, then?
/* Specify the number of elements of a function's array parameter,
as in 'int f (int n, int arr[_REGEX_NELTS (n)]);'
if arr may be NULL,
or 'int f (int n, int arr[_REGEX_NELTS (static n)]);'
if arr must be non-NULL. */
Bruno
[1]
https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/Common-Function-Attributes.html