You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
An array length must be a decimal number: long[QWORDS] with a const QWORDS does not parse, and byte[0x40] is 0 #3115
The length of a fixed-size array must be written as a decimal number. A module that names its sizes cannot use those names where the size matters most:
So std writes long[128] beside const QWORDS: int = 128, and the two can drift apart. The parser also reads the number with atoi, so a hex length (byte[0x40]) is taken as 0.
Fix: an array length is an integer constant expression: a literal in any base the language accepts, a const of the same file whose value is one, or + - * / % << >> and parentheses over those. This holds in every place a length is written: local declarations, struct fields, parameters, actor state, const tables and make's array forms. A name that is not an integer constant is a compile error saying so, and so is a length that is zero or less. The reference states the rule in Array Types, and the std modules that wrote a number beside a named size use the name.
Found on #3101 (#3107, moving argon2's and skein's scratch buffers onto arrays).
Activity
An array length is an integer constant expression: a named constant, …
std.bignum and the cryptography modules hold their buffers as arrays …