qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-trivial] [Qemu-devel] [PATCH] pci: Fix compiler warning (MinGW


From: Eric Blake
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] pci: Fix compiler warning (MinGW-w64 gcc 4.9)
Date: Thu, 14 May 2015 15:30:17 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

On 05/14/2015 03:16 PM, Eric Blake wrote:
> On 05/14/2015 03:06 PM, Eric Blake wrote:
>> On 05/14/2015 02:38 PM, Stefan Weil wrote:
>>> i686-w64-mingw32-gcc 4.9.1 from Debian Jessie complains:
>>>
>>> hw/pci/pci.c:938:29: warning:
>>>  array subscript is above array bounds [-Warray-bounds]
>>>
>>> Using g_assert instead of assert fixes this warning.
>>
>> Is that because the mingw headers don't properly mark the expansion of
>> the failed branch of assert() as noreturn, whereas g_assert() does, and
>> therefore the compiler has more information about what variables must be
>> if the rest of the function is reached?
>>
> 
>>
>> Meanwhile, you may want to file a bug to the mingw maintainers that
>> their header is puny when compared to glibc assert() or to glib's
>> g_assert, when it comes to giving gcc decent hints.
> 
> Oh, I was right!
> 
> glibc /usr/include/assert.h:

> vs mingw /usr/i686-w64-mingw32/sys-root/mingw/include/assert.h:

and glib's version in /usr/include/glib-2.0/glib/gtestutils.h:
#define g_assert(expr)                  G_STMT_START { \
                                             if G_LIKELY (expr) ; else \
                                               g_assertion_message_expr
(G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \

 #expr); \
                                        } G_STMT_END

GLIB_AVAILABLE_IN_ALL
void    g_assertion_message_expr        (const char     *domain,
                                         const char     *file,
                                         int             line,
                                         const char     *func,
                                         const char     *expr)
G_GNUC_NORETURN;


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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]