[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] packed structures and unaligned accesses (sparc)
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] packed structures and unaligned accesses (sparc) |
Date: |
Tue, 28 Mar 2017 11:23:14 +0100 |
On 28 March 2017 at 11:19, John Paul Adrian Glaubitz
<address@hidden> wrote:
> On 03/27/2017 07:34 PM, Peter Maydell wrote:
>> That all makes sense in isolation, but shouldn't something have
>> at least warned that "&h.size" isn't actually a uint32_t* in
>> the sense of being something you can validly pass to a
>> function that takes a uint32_t* ?
>
> It turns out that clang actually emits a warning in this case:
>
> address@hidden:~# clang-4.0 packed.c -o packed
> packed.c:18:18: warning: taking address of packed member 'size' of class or
> structure 'hdr' may result in an unaligned pointer value
> [-Waddress-of-packed-member]
> return getval(&h.size);
> ^~~~~~
> 1 warning generated.
> address@hidden:~#
Ah, good. (Unfortunately my clang isn't new enough for that,
being 3.8.)
thanks
-- PMM