Peter Xu <pet...@redhat.com> writes:

> On Wed, Mar 09, 2016 at 09:34:50AM +0100, Markus Armbruster wrote:
>> Peter Xu <pet...@redhat.com> writes:
>> > It's dynamically allocated in stack, can we still use ARRAY_SIZE in
>> > this case?
>> 
>> ARRAY_SIZE(x) is defined as (sizeof(x) / sizeof((x)[0])).  Works when x
>> is of array type (variable length array is fine).  Screws up when x is
>> of *pointer* type.
>> 
>> C99  6.5.3.4:
>> 
>>     The sizeof operator yields the size (in bytes) of its operand, which
>>     may be an expression or the parenthesized name of a type.  The size
>>     is determined from the type of the operand.  The result is an
>>     integer.  If the type of the operand is a variable length array
>>     type, the operand is evaluated; otherwise, the operand is not
>>     evaluated and the result is an integer constant.
>
> Good to know it. Thanks! :) 
>
> However, ARRAY_SIZE() still cannot help solving the unbounded stack
> issue, right?

Measuring the size of the array doesn't change the size of the array :)

Reply via email to