https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85923
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Does -fno-strict-aliasing fix this? I suspect the issue is the pointers types "char*" and "unsigned char*" are considered to be different aliasing groups (which is correct) and that is causing gcc to output code that you don't expect.