From 902e4335501e73ad45ad2ebc2510b1d41786873f Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 31 Jul 2012 09:02:35 +0000 Subject: libiberty/md5: fix strict alias warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Current libiberty md5 code triggers these warnings with gcc-4.7.1 for me: libiberty/md5.c: In function ‘md5_finish_ctx’: libiberty/md5.c:117:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] libiberty/md5.c:118:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] The change below fixes things for me. The optimized output (-O2) is the same before/after my change on x86_64-linux. I imagine it'll be the same for most targets. It seems simpler than using a union on the md5_ctx buffer since these are the only two locations in the code where this occurs. --- libiberty/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libiberty/ChangeLog') diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 349dc98..6615047 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,8 @@ +2012-07-31 Mike Frysinger + + * md5.c (md5_finish_ctx): Declare swap_bytes. Assign SWAP() output + to swap_bytes, and then call memcpy to move it to ctx->buffer. + 2012-07-26 Kazu Hirata Sandra Loosemore -- cgit v1.1