Subject: | Consolidate byte-swapping paths to avoid undefined behavior |
Date: | Wed, 11 Sep 2019 10:14:54 -0700 |
To: | bug-Digest-MD5 [...] rt.cpan.org |
From: | Matt Turner <mattst88 [...] gmail.com> |
Pull request containing fix is at https://github.com/gisle/digest-md5/pull/16
The code guarded by #ifndef U32_ALIGNMENT_REQUIRED attempts to optimize
byte-swapping by doing unaligned loads, but accessing data through
unaligned pointers is undefined behavior in C. Moreover, compilers are
more than capable of recognizing these open-coded byte-swap patterns and
emitting a bswap instruction, or an unaligned load instruction, or a
combined load, etc. There's no need for multiple paths to attain the
desired result.
See https://rt.perl.org/Ticket/Display.html?id=133495