https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112442
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> --- The aliasing doesn't happen when writing to the array, it's when reading a char* value from an object of type unsigned char*. If you just passed the unsigned char* to memcpy instead of *(char**)&ptr it would be OK. memcpy(*&ptr, ...) would also be OK.