This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PING][PATCH] Fix PR middle-end/26565, memcpy alignment issue


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]