From: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
To: Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org
Cc: dgilbert@redhat.com, quintela@redhat.com
Subject: Re: [Qemu-devel] [PATCH] migration/rdma: clang compilation fix
Date: Mon, 4 Mar 2019 20:30:22 +0200 [thread overview]
Message-ID: <a18b38a0-fd94-f478-d25a-a1a7ba73b1a1@gmail.com> (raw)
In-Reply-To: <550bead8-a9a5-d9f4-1204-a6130f8c8e14@redhat.com>
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.o
>> qemu/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 <marcel.apfelbaum@gmail.com>
>> ---
>> migration/rdma.c | 3 +++
>> 1 file changed, 3 insertions(+)
prev parent reply other threads:[~2019-03-04 18:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-04 8:42 [Qemu-devel] [PATCH] migration/rdma: clang compilation fix Marcel Apfelbaum
2019-03-04 18:11 ` Eric Blake
2019-03-04 18:18 ` Dr. David Alan Gilbert
2019-03-04 18:27 ` Marcel Apfelbaum
2019-03-04 18:30 ` Marcel Apfelbaum [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a18b38a0-fd94-f478-d25a-a1a7ba73b1a1@gmail.com \
--to=marcel.apfelbaum@gmail.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).