Progmasoft Git

progmasoft-cpp

The C++ style guide of Progmasoft: naming, formatting, language rules, errors, ownership, ABI, testing and tooling.

Clonegit clone https://git.progmasoft.com/progmasoft-cpp

Advise against variable-length arrays in GNU99

Variable-length arrays are allowed in GNU99, as in C99, but should not be
used: their size is not checked against the stack, and C11 makes them
optional. A buffer sized at run time should be allocated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Commit
148776bb40a3dd2656ed1c0b65f26054bda9d3b8
Author
Leitwolf11 ·
Parents
72b5b4ac317d

Files · Download .tar.gz

Changes

 Progmasoft_Core_C_Coding_Guidelines/Gnu99/LANGUAGE.md | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Progmasoft_Core_C_Coding_Guidelines/Gnu99/LANGUAGE.md b/Progmasoft_Core_C_Coding_Guidelines/Gnu99/LANGUAGE.md
index 7eddffa..caf32c9 100644
--- a/Progmasoft_Core_C_Coding_Guidelines/Gnu99/LANGUAGE.md
+++ b/Progmasoft_Core_C_Coding_Guidelines/Gnu99/LANGUAGE.md
@@ -38,6 +38,12 @@ if(__builtin_mul_overflow(aCount, sizeof(*pValues), &bytes))
         return (false);
 ```
 
+## Variable-length arrays
+
+- **Variable-length arrays should not be used**, although C99 has them and GNU99 allows them. Their size is not
+  checked against the stack, and C11 makes them optional. A buffer whose size is known only at run time should be
+  allocated ([Memory and ownership](../Common/MEMORY-AND-OWNERSHIP.md#82-allocating)).
+
 ## The GNU99 form of the C11 features
 
 | C11 | GNU99 |