At that moment, the line ain't completely parsed and validated.

Hence argc is still unknown to the compiler.

Gcc allows this, but Gcc is not conformant and creates "extensions" as it see 
fit.

Regards.

----- Mail d'origine -----
De: John Scott <[email protected]>
À: [email protected]
Envoyé: Mon, 28 Feb 2022 08:06:13 +0100 (CET)
Objet: [Tinycc-devel] TinyCC does not accept variable-length static qualifier 
for function parameter arrays

Hi,

Although this is a conformant C99 program, TinyCC chokes on the
following single line program with 'error: argc undeclared':
        int main(int argc, char *argv[static argc+1]) {}

If you're not aware, the static qualifier, when used like this,
indicates that argv must point to an array of at least argc+1 elements.
This can be useful for bounds checking or optimization, but TinyCC
should not fail to compile it. Some other functions this can be useful
with are
        int getgroups(int s, gid_t[static s]);
        int regexec(const regex_t r[restrict static 1], const char s[restrict 
static 1], size_t n, regmatch_t m[restrict static n], int w);


_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to