https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112442
--- Comment #4 from Adam Andersson <adam.andersson at elisapolystar dot com> --- (In reply to Andrew Pinski from comment #3) > I am not 100% sure but there seems like some kind of aliasing issue going on. > > Basically you have a pointer to an `unsigned char` but writing it via a > pointer to `char`. > Yes writing to a type via `char` would be valid and well defined but you are > writing to a pointer of char. Something weird is going on when casting a char pointer to an unsigned char pointer. If you replace the unsigned char pointer with a void pointer it works fine.