On Wed, Feb 17, 2016 at 12:29:34AM +0000, Stuart Brady wrote: > > - should __array_size (b) be an integer constant (size_t)2, or should it > > be non-constant (size_t)2 because the argument is a VLA (albeit a VLA > > whose top-level dimension is an integer constant expression)? > > Ouch. I would say it should be an integer constant (size_t)2, simply as > that seems to me to be a reasonable expectation. Unfortunately, this is > not what happens with my patch, as I get a -Wint-conversion warning. :-(
[snip] Okay. So, unsurprisingly, it turns out the problem here was in my code. When I added c_expr_array_size_expr() and c_expr_array_size_type() it seems I had not understood that C_TYPE_VARIABLE_SIZE and therefore also c_vla_type_p are non-zero (true) for VLAs where the outermost subscript is not variable, behaviour I can now clearly see in grokdeclarator(). This certainly supports the notion that test cases and documentation are of greater importance than the patch itself, at this stage. I now seem to have an __array_size keyword that behaves as I would expect in this case, too. I'll resubmit the patch once I have gone through the final draft of C11. It is still not entirely clear to me whether I must do something to prevent constant folding for use of __array_size with VLAs, but I am not so highly concerned just at the moment. -- Many thanks, Stuart Brady