Re: Memory alignment
Keith Thompson <kst-u@mib.orgwrites :
Ahhh, okay. Accessing obj.arr[1] is always undefined behavior,
whether (struct h) has padding bytes or not.
Keith Thompson <kst-u@mib.orgwrites :
Tim Rentsch <txr@alumnus.ca ltech.eduwrites :
[...]
I'm sure someone with Larry Jones's credentials must be saying
something by this, but I'll be darned if I know what it is. Surely
padding bytes must be available for writing to, at least as unsigned
char, so functions with a qsort-like interface can be written.
>
The context was a discussion of the struct hack. For example, given:
>
struct h {
int i;
char arr[1];
};
struct h obj;
>
>[...]
lawrence.jones@ siemens.com writes:
No, the padding bytes are most definitely *not* yours to write to.
Although most implementations will let you get away with it, there are
implementations that do careful memory bounds checking and won't.
Although most implementations will let you get away with it, there are
implementations that do careful memory bounds checking and won't.
something by this, but I'll be darned if I know what it is. Surely
padding bytes must be available for writing to, at least as unsigned
char, so functions with a qsort-like interface can be written.
The context was a discussion of the struct hack. For example, given:
>
struct h {
int i;
char arr[1];
};
struct h obj;
>
>[...]
whether (struct h) has padding bytes or not.
Comment