when libibiberty's md5.c is built using 4.7 or trunk on x86-linux, the following warning is emitted: md5.c: In function 'md5_finish_ctx': md5.c:119:2: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] *(md5_uint32 *) & ctx->buffer[bytes + pad] = SWAP (ctx->total[0] << 3); ^ md5.c:120:2: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] *(md5_uint32 *) & ctx->buffer[bytes + pad + 4] = ^ afaics this is the only warning emitted when building libiberty when built with 4.7 or trunk.
Created attachment 27511 [details] patch taken from glibc the md5.c copy in glibc was fixed with the attached patch
the patch is incomplete. the patch from glibc is found at http://sourceware.org/git/?p=glibc.git;a=patch;h=7dc6bd90c569c49807462b0740b18e32fab4d8b7 using anonymous unions which cannot be used for stage1. The original patch is http://sourceware.org/ml/libc-alpha/2011-07/msg00085.html A third approach from gnulib is pointed out in http://sourceware.org/ml/libc-alpha/2011-07/msg00093.html
Author: ktietz Date: Thu Jan 31 08:14:27 2013 New Revision: 195601 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195601 Log: Merged from trunk. PR other/53285 * md5.c (md5_finish_ctx): Declare swap_bytes. Assign SWAP() output to swap_bytes, and then call memcpy to move it to ctx->buffer. Modified: branches/gcc-4_7-branch/libiberty/ChangeLog branches/gcc-4_7-branch/libiberty/md5.c
backported mainline-fix for this to 4.7. Fixed.