On 28 March 2017 at 11:19, John Paul Adrian Glaubitz <glaub...@physik.fu-berlin.de> 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: > > root@deb4g:~# 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. > root@deb4g:~#
Ah, good. (Unfortunately my clang isn't new enough for that, being 3.8.) thanks -- PMM