diff --git a/include/regex.h b/include/regex.h index 24eca2c297..5cf3ef7636 100644 --- a/include/regex.h +++ b/include/regex.h @@ -37,7 +37,8 @@ extern int __regcomp (regex_t *__preg, const char *__pattern, int __cflags); libc_hidden_proto (__regcomp) extern int __regexec (const regex_t *__preg, const char *__string, - size_t __nmatch, regmatch_t __pmatch[], int __eflags); + size_t __nmatch, regmatch_t __pmatch[_VLA_ARG (__nmatch)], + int __eflags); libc_hidden_proto (__regexec) extern size_t __regerror (int __errcode, const regex_t *__preg, diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h index e490fc1aeb..6b6e4c233c 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -632,4 +632,14 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf # define __attribute_returns_twice__ /* Ignore. */ #endif + +#if (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__ \ + && !defined __STDC_NO_VLA__) +/* Used to specify a variable bound in a declaration of a function + VLA-like parameter, as in 'int f (int n, int[_VLA_ARG (n)n]);' */ +# define _VLA_ARG(arg) arg +#else +# define _VLA_ARG(arg) +#endif + #endif /* sys/cdefs.h */ diff --git a/posix/regex.h b/posix/regex.h index 14fb1d8364..52ccc4b577 100644 --- a/posix/regex.h +++ b/posix/regex.h @@ -654,9 +654,8 @@ extern int regcomp (regex_t *_Restrict_ __preg, extern int regexec (const regex_t *_Restrict_ __preg, const char *_Restrict_ __String, size_t __nmatch, - regmatch_t __pmatch[_Restrict_arr_], - int __eflags) - __attr_access ((__write_only__, 4, 3)); + regmatch_t __pmatch[_Restrict_arr_ _VLA_ARG (__nmatch)], + int __eflags); extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg, char *_Restrict_ __errbuf, size_t __errbuf_size)