|
From: | Marcel Apfelbaum |
Subject: | Re: [Qemu-devel] [PATCH] migration/rdma: clang compilation fix |
Date: | Mon, 4 Mar 2019 20:30:22 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 |
On 3/4/19 8:11 PM, Eric Blake wrote:
On 3/4/19 2:42 AM, Marcel Apfelbaum wrote:Configuring QEMU with: ../configure --cc=clang --enable-rdma Leads to compilation error: CC migration/rdma.o CC migration/block.oqemu/migration/rdma.c:3615:58: error: taking address of packed member 'rkey' of class or structure 'RDMARegisterResult' may result in an unaligned pointer value [-Werror,-Waddress-of-packed-member] (uintptr_t)host_addr, NULL, ®_result->rkey,^~~~~~~~~~~~~~~~ This is a false warning; even if RDMARegisterResult is "packed", rkey is the first field so is guaranteed to be aligned.Not so. If you packed struct, gcc is free to abut that struct next to some other unaligned field in a larger struct:https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg06743.html
I wasn't referring to general case, but to this specific case. Actually gcc does not complain, only clang.
Anyway, Dave's suggestion is clean and works for me. Thanks, Marcel
Fix it by disabling the warning only for this instance.Ignoring the bug is not the same as fixing the bug. You need to rework this, as the compiler warning is not a false negative.Signed-off-by: Marcel Apfelbaum <address@hidden> --- migration/rdma.c | 3 +++ 1 file changed, 3 insertions(+)
[Prev in Thread] | Current Thread | [Next in Thread] |