lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


That's the second sentence, "Unless explicitly stated otherwise in the
description of a particular function in this subclause, pointer
arguments on such a call shall still have valid values, as described
in 7.1.4.", where "such a call" is a call with zero size.

  OG.


On Mon, Aug 24, 2015 at 7:05 AM, Tim Hill <drtimhill@gmail.com> wrote:
>
> On Aug 23, 2015, at 4:36 PM, Igor Ehrlich <iehrlich@iponweb.net> wrote:
>
>> C99 specifies that it is fine to pass zero to memcpy as the size
>> parameter.
>
> 7.24.1(2): Where an argument declared as size_t n specifies the length of
> the array for a
> function, n can have the value zero on a call to that function. Unless
> explicitly stated
> otherwise in the description of a particular function in this subclause,
> pointer arguments
> on such a call shall still have valid values, as described in 7.1.4. On such
> a call, a
> function that locates a character finds no occurrence, a function that
> compares two
> character sequences returns zero, and a function that copies characters
> copies zero
> characters.
>
>
> My question wasn't about passing zero as the size/length, it was about
> acceptable values for the associated memory pointers when the size was zero.
> On two different occasions I’ve had C runtimes that have faulted when passed
> a NULL pointer to (say) memcpy when the length was zero. I agree that this
> is not in accordance with standards, nor is it particularly sensible, but I
> wanted clarity on how Lua handled such a situation (since the specs are
> silent on this).
>
> —Tim
>