This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PING][PATCH] Fix PR middle-end/26565, memcpy alignment issue
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 10 Mar 2006 13:38:37 +0100 (CET)
- Subject: [PING][PATCH] Fix PR middle-end/26565, memcpy alignment issue
- References: <Pine.LNX.4.63.0603061548130.27394@t148.fhfr.qr>
On Mon, 6 Mar 2006, Richard Guenther wrote:
>
> This patch fixes PR26565, emitting unaligned stores for
>
> void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n);
>
> struct timeval {
> long tv_sec;
> };
>
> struct outdata {
> char seq;
> struct timeval tv __attribute__((packed));
> };
>
> void send_probe(struct outdata *outdata, struct timeval *tp)
> {
> memcpy(&outdata->tv, tp, sizeof outdata->tv);
> }
>
> on STRICT_ALIGNMENT targets. builtins.c:get_pointer_alignment is simply
> overly optimistic about the alignment it can infer. Fixed by looking
> through component references and taking into account their DECL_ALIGN.
>
> The only way to workaround the bug I found is to use (char*)outdata+1 for
> the destination parameter. A direct assignment outdata->tv = *tp also
> works as expected.
>
> Boostrapped and regtested on ia64-unknown-linux-gnu.
Additionally bootstrapped and regtested on i686, s390, s390x and x86_64.
> Ok for mainline, 4.1 and 4.0?
Ping?
Richard.