Earlier quoted context omitted.
> Actually, casts to/from char * are always defined in C (chars are always assumed to alias). Not true. The standard says you can access any object's value via the char type, but not the reverse. You can't cast a character array to any type and dereference it. > The author was talking about "chunking" non-char units. Sure, but you can call my copy_8_bytes() function like so legally: int64_t a, b = 0; copy_8_bytes(&a,…
> You can't cast a character array to any type and dereference it. So making your own malloc backed by a static char array is undefined behavior?
The "effective type" (this is a term defined in the standard) of the char array elements would be "char", whereas the memory returned from malloc() is considered to be an object that initially has no effective type. I don't know of any way to take the char array and "erase" its effective type so that it can be used generically, like the value returned from malloc().
This is a problem!