From fa83b7df5a0711bf5f4a5162cc33b0a4123a53c7 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Thu, 22 Oct 2026 15:06:13 +0000 Subject: fix(arrays): reject inverted bounds and check array allocation Constant inverted bounds are a compile error and other bounds are checked at run time. Allocation sizes use overflow-checked arithmetic, and a NULL malloc (including the BYVAL copy) reports that the array is too large. Co-Authored-By: Claude Sonnet 5.5 --- doc/language/keyword/cpsc-keyword-declare.7.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/language/keyword/cpsc-keyword-declare.7.md b/doc/language/keyword/cpsc-keyword-declare.7.md index 6138916..6860ff5 100644 --- a/doc/language/keyword/cpsc-keyword-declare.7.md +++ b/doc/language/keyword/cpsc-keyword-declare.7.md @@ -17,7 +17,7 @@ Declare one variable per statement. Built-in types are INTEGER (signed 64-bit), C_INT, C_CHAR, C_STRING and C_DOUBLE are native C aliases for int, char, char* and double. C_TYPE can introduce aliases for other supported C base types and pointers. C values start with zero or null; assignment from pseudocode types requires an explicit cast. See [cpsc-keyword-c_type(7)](cpsc-keyword-c_type.7.md). -ARRAY bounds are inclusive and may be expressions; multiple ranges create multiple dimensions. Access elements with `name[index, ...]`. Bounds are checked at run time; an invalid index throws an exception that TRY/CATCH can handle. Whole-array assignment is unsupported. Declare arrays before using them; arrays declared inside a control-flow block stay in that block. +ARRAY bounds are inclusive and may be expressions; every dimension needs an upper bound that is at least the lower bound (constant bounds that are inverted are a compile error, other bounds a run-time error), and an array too large to allocate is a run-time error; multiple ranges create multiple dimensions. Access elements with `name[index, ...]`. Bounds are checked at run time; an invalid index throws an exception that TRY/CATCH can handle. Whole-array assignment is unsupported. Declare arrays before using them; arrays declared inside a control-flow block stay in that block. For class variables, an optional argument list after the type supplies constructor arguments, such as `DECLARE Item : Counter(3)`. Declarations zero storage and automatically construct class fields and array elements before calling the outer constructor. See [cpsc-keyword-class(7)](cpsc-keyword-class.7.md) for construction and NEW rebinding rules. -- cgit v1.3.1-4-g156e