[RFC] [PATCH] Add __array_size keyword
Joseph Myers
joseph@codesourcery.com
Thu Feb 11 22:41:00 GMT 2016
On Thu, 11 Feb 2016, Stuart Brady wrote:
> Documentation and test code are currently absent from the patch, but I
For proposed features, I find documentation and testcases of much more
value than the rest of the implementation. Critical issues to define and
cover thoroughly in tests include the rules for when operands of sizeof
are evaluated, as adapted appropriately for this keyword, and for when it
returns various kinds of constants. Is the rule for your keyword that the
operand is evaluated, and the result not an integer constant, iff the
operand is an array with a variable number of elements (as opposed to an
array with a constant number of elements that themselves are
variable-sized, for example)? C11 6.5.3.4#2 (sizeof) would need testing,
but so would 6.9#3 (rules about when declared identifiers need to be
defined), and 6.6#6 and #8 (constant expressions) - and anything else in
C11 that mentions sizeof. Presumably this keyword can be applied to an
array at function prototype scope whose size is explicitly or implicitly
[*], though nothing useful can be done with the results, as with [*]?
(Cf. gcc.dg/vla-5.c.)
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Gcc-patches
mailing list