Subject: Re: gcc4 lossage on mips kernels with semi-packed struct
To: Simon Burge <>
From: None <>
List: tech-toolchain
Date: 05/16/2006 19:28:54
In message <>Simon Burge write
>I've made a simple test case:
>    struct in_addr {
>	unsigned int s_addr;
>    } __attribute__((__packed__));
>    struct bootpcontext {
>	char expected_dhcpmsgtype, dhcp_ok;
>	struct in_addr serverip;
>    };
>    void
>    bootpcheck(int *p, struct bootpcontext *bpc)
>    {
>	memcpy(&bpc->serverip.s_addr, p, sizeof(bpc->serverip.s_addr));
>    }
>This generates:
>        lw      $2,0($4)
>        j       $31
>        sw      $2,2($5)
>Before we submit a bug report to gcc, do any language lawyers have any
>comments on what this is doing?  The description of -Wpacked from "info
>gcc" says that we can expect serverip.s_addr in struct bootpcontext to
>be unaligned, so it would seem that the memcpy optimisation is wrong in
>forgetting about the packed attribute.

hi Simon,

Speaking as a former gcc port-maintainer for a long-dead RISC CPU:
What you write is a fine bug-report.  But going the extra 1500m, and
testing with -fno-builtins to ascertain if that truly makes the
problem go away, would be even better :-).

Is builtin memcpy really the culprit? Oh, taste the irony.
Please let me know (off-list if you deem appropriate.)