|
|
|
|
|
by MaulingMonkey
3544 days ago
|
|
To try and give some actual examples: Undefined: int64_t a = 42;
void* p = &a;
int32_t* i = p;
printf("%i", *i);
Implementation defined, as type punning to char is legal (allowing the implementation of memcpy): int64_t a = 42;
void* p = &a;
char* ch = p;
printf("%c", *ch);
Exercise left to the reader: Implement a "fast" memcpy (e.g. one that will copy more than 1 byte at a time for large copies, as your standard library implementation likely does) without violating strict aliasing rules. |
|