[libvirt] [PATCH] build: work around gcc 6.0 warnings

Eric Blake eblake at redhat.com
Thu Feb 25 13:48:29 UTC 2016


On 02/25/2016 04:15 AM, Pavel Hrdina wrote:
> On Wed, Feb 24, 2016 at 02:29:58PM -0700, Eric Blake wrote:
>> gcc 6.0 added an annoying warning:
>>
>> fdstream.c: In function 'virFDStreamWrite':
>> fdstream.c:390:29: error: logical 'or' of equal expressions [-Werror=logical-op]
>>         if (errno == EAGAIN || errno == EWOULDBLOCK) {
>>                             ^~
>> fdstream.c: In function 'virFDStreamRead':
>> fdstream.c:440:29: error: logical 'or' of equal expressions [-Werror=logical-op]
>>         if (errno == EAGAIN || errno == EWOULDBLOCK) {
>>                             ^~
>>
>> This makes it impossible to build out-of-the-box on rawhide,
>> and we aren't guaranteed that the gcc bug will be fixed in a
>> timely manner:
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602
>>
>> So work around it by further complicating the logic to thwart the
>> compiler.
> 
> Personally I don't like this approach.  Why don't we take that 6 line reproducer
> from GCC BZ and create a m4 macro that will detect that bug in GCC and turn off
> the logical-op check?  For me this solution is much cleaner than introducing
> some ugly workaround in our code just because GCC has a bug.

Killing it for the entire tree seems like a rather heavy hammer.  I'd
rather just add #pragma push/pop to ignore the warning around the few
places that it incorrectly triggers, leaving the rest of the tree still
protected (as it does catch real bugs, when we aren't dealing with
sometimes-aliased values coming from headers).

I'll work up a v2 along those lines, so we can compare the two approaches.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160225/af5b5e82/attachment-0001.sig>


More information about the libvir-list mailing list