Bug 53285 - libibiberty's md5.c builds with warnings with 4.7 and trunk
Summary: libibiberty's md5.c builds with warnings with 4.7 and trunk
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-08 22:22 UTC by Matthias Klose
Modified: 2013-01-31 08:21 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
patch taken from glibc (323 bytes, patch)
2012-05-28 04:38 UTC, Matthias Klose
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Klose 2012-05-08 22:22:10 UTC
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.
Comment 1 Matthias Klose 2012-05-28 04:38:50 UTC
Created attachment 27511 [details]
patch taken from glibc

the md5.c copy in glibc was fixed with the attached patch
Comment 2 Matthias Klose 2012-05-28 06:42:37 UTC
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
Comment 3 Kai Tietz 2013-01-31 08:14:32 UTC
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
Comment 4 Kai Tietz 2013-01-31 08:21:48 UTC
backported mainline-fix for this to 4.7.  Fixed.