Re: Lua define ARRAY_FLEXIBLE_MEMBER
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Lua define ARRAY_FLEXIBLE_MEMBER
- From: Roberto Ierusalimschy <roberto@...>
- Date: 2022年11月15日 11:31:57 -0300
> Hm, i hate reading ISO standard so the exact wording i do not
> know, but the above makes me think you do enter undefined area by
> storing more in .data than is allowed (likely depending on
> C compiler flags and optimization too, i have not looked what Lua
> uses).
There is nothing undefined here; it is all valid ISO C. The code
does not store anything *in* 'data'. When we write cl->data[i], that
means *(cl->data + i). It only gets the address and type of 'cl->data',
the rest is pointer arithmetic. As long as the result of the addition
is aligned, has the correct type, and points inside the same object,
everything is well defined.
-- Roberto