lua-users home
lua-l archive

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


On Fri, May 15, 2020 at 8:00 PM Philippe Verdy <verdyp@gmail.com> wrote:
> Le ven. 15 mai 2020 à 17:06, Francisco Olarte <folarte@peoplecall.com> a écrit :
>> That "prepadding" is, IMNSHO, an invention of yours.
> No, "prepadding" is what happens to align a new added field to respect its alignment contraint (i.e. determining its starting offset). "postpadding" is never needed anywhere for any type (independantly of their alignment constraint or usable size).

No. You, Philippe Verdy, define prepadding as "what happens.....". It
is not a widely used and recognized term.

>   struct f1 { int a; char b; }
> then its sizeof should still be 5, its alignof should be 4.

IIRC I sent you a program proving it was not on a similar thing, but
let do it again:
<<<<
$ cat kk.c
#include <stdio.h>
struct f1 { int a; char b; };
int main(int ac, char **av) {
  printf("%d\n", (int)sizeof(struct f1));
  return 0;
}
$ gcc kk.c
$ ./a.out
8
>>>>

As much as I may respect your opinion, I'll trust gcc over you here.

And I show my code, not limit myself to "it should do this or that".

Well, to be fair, I do not know if it SHOULD be 5, but I know it IS 8.

> In old C, there was only sizeof() documented (and legacy memory allocators like malloc/calloc did not care about alignment constraints)

I can assure you they cared. I've worked with old, preansi, compilers
on machines with weird align requirements and malloc always took care
of not returning unaligned pointers. AAMOF they normally were OVER
aligned.

Francisco Olarte.
_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org