qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] SLIRP warning messages displayed while compiling


From: Peter Maydell
Subject: Re: [Qemu-devel] SLIRP warning messages displayed while compiling
Date: Sat, 12 Aug 2017 11:53:20 +0100

On 11 August 2017 at 22:58, Samuel Thibault <address@hidden> wrote:
> Hello,
>
> Programmingkid, on jeu. 10 août 2017 16:44:19 -0400, wrote:
>> While compiling I saw these error messages:
>>
>> slirp/ip6_icmp.c:79:32: warning: taking address of packed member 'ip_src' of 
>> class or
>>       structure 'ip6' may result in an unaligned pointer value
>>       [-Waddress-of-packed-member]
>>     if (IN6_IS_ADDR_MULTICAST(&ip->ip_src) ||
>>                                ^~~~~~~~~~
>
>> slirp/ip_input.c:159:43: warning: taking address of packed member 'ip_link' 
>> of class or
>>       structure 'ipq' may result in an unaligned pointer value
>>       [-Waddress-of-packed-member]
>>                 for (l = slirp->ipq.ip_link.next; l != &slirp->ipq.ip_link;
>>                                                         ^~~~~~~~~~~~~~~~~~
>
> Well, if the compiler was counting well, it would notice that the
> structure are made so that even with packing, fields always get aligned
> on proper bounds.

The utility of the warning is that it means you get told
about stuff that might break on other architectures. Eg
x86's alignment restrictions are practically nonexistent
but sparc is much more restrictive. It's better to get
warnings on all hosts so these things can be cleaned
up rather than have them only be warnings on the less
commonly used hosts where nobody will notice them.

(GCC ideally ought to warn about this but doesn't:
that's a bug/missing feature in gcc.)

That said, some of these are a bit odd -- comparing
a pointer value should be fine, as should using
a pointer to a packed struct field inside a
function -- it's only when that pointer is cast
to a non-packed-pointer-type (including by passing
it to another function) that the compiler loses the
information that the pointer is potentially unaligned.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]