All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Stefan Weil <sw@weilnetz.de>, QEMU Trivial <qemu-trivial@nongnu.org>
Cc: QEMU Developer <qemu-devel@nongnu.org>
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	[thread overview]
Message-ID: <555513E9.3010601@redhat.com> (raw)
In-Reply-To: <555510C2.7020507@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1842 bytes --]

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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Eric Blake <eblake@redhat.com>
To: Stefan Weil <sw@weilnetz.de>, QEMU Trivial <qemu-trivial@nongnu.org>
Cc: QEMU Developer <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] pci: Fix compiler warning (MinGW-w64 gcc 4.9)
Date: Thu, 14 May 2015 15:30:17 -0600	[thread overview]
Message-ID: <555513E9.3010601@redhat.com> (raw)
In-Reply-To: <555510C2.7020507@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1842 bytes --]

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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  parent reply	other threads:[~2015-05-14 21:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-14 20:38 [Qemu-trivial] [PATCH] pci: Fix compiler warning (MinGW-w64 gcc 4.9) Stefan Weil
2015-05-14 20:38 ` [Qemu-devel] " Stefan Weil
2015-05-14 21:06 ` [Qemu-trivial] " Eric Blake
2015-05-14 21:06   ` Eric Blake
2015-05-14 21:16   ` [Qemu-trivial] " Eric Blake
2015-05-14 21:16     ` Eric Blake
2015-05-14 21:22     ` [Qemu-trivial] " Eric Blake
2015-05-14 21:22       ` Eric Blake
2015-05-14 21:30     ` Eric Blake [this message]
2015-05-14 21:30       ` Eric Blake
2015-05-15  8:00 ` [Qemu-trivial] " Markus Armbruster
2015-05-15  8:00   ` Markus Armbruster
2015-05-15 16:20   ` [Qemu-trivial] " Eric Blake
2015-05-15 16:20     ` Eric Blake

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=555513E9.3010601@redhat.com \
    --to=eblake@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=sw@weilnetz.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.