[Bug c/57862] invalid read struct uint32_t member (ARMV5)
mikpe at it dot uu.se
gcc-bugzilla@gcc.gnu.org
Wed Jul 10 10:31:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57862
--- Comment #5 from Mikael Pettersson <mikpe at it dot uu.se> ---
Your test case contains this:
===snip===
struct iphdr
{
...
};
...
int main()
{
char thePacket[1518];
memset(thePacket, 0, 1518);
thePacket[30] = 1;
thePacket[31] = 2;
thePacket[32] = 3;
thePacket[33] = 4;
struct ether_header* theEthHeader = (struct ether_header*)(thePacket);
struct iphdr* theIpHeader = (struct iphdr*)((const unsigned
char*)(theEthHeader) + 14);
struct in_addr myInAddr;
myInAddr.s_addr = theIpHeader->daddr;
===snip===
The alignment of thePacket is arbitrary, so the alignment of theIpHeader is
unknown, and struct iphdr is not declared with attribute packed. The final
load may therefore be misaligned.
More information about the Gcc-bugs
mailing list