From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yt0Kx-00034t-3H for qemu-devel@nongnu.org; Thu, 14 May 2015 17:06:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yt0Kt-0006rC-Tg for qemu-devel@nongnu.org; Thu, 14 May 2015 17:06:35 -0400 Message-ID: <55550E54.2080405@redhat.com> Date: Thu, 14 May 2015 15:06:28 -0600 From: Eric Blake MIME-Version: 1.0 References: <1431635892-31996-1-git-send-email-sw@weilnetz.de> In-Reply-To: <1431635892-31996-1-git-send-email-sw@weilnetz.de> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="XAqw65qs5CKlKHCddCCIXkrrgpDt2OFFJ" Subject: Re: [Qemu-devel] [PATCH] pci: Fix compiler warning (MinGW-w64 gcc 4.9) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil , QEMU Trivial Cc: QEMU Developer This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --XAqw65qs5CKlKHCddCCIXkrrgpDt2OFFJ Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05/14/2015 02:38 PM, Stefan Weil wrote: > i686-w64-mingw32-gcc 4.9.1 from Debian Jessie complains: >=20 > hw/pci/pci.c:938:29: warning: > array subscript is above array bounds [-Warray-bounds] >=20 > 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? >=20 > Signed-off-by: Stefan Weil > --- > hw/pci/pci.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/hw/pci/pci.c b/hw/pci/pci.c > index 48f19a3..34f71dc 100644 > --- a/hw/pci/pci.c > +++ b/hw/pci/pci.c > @@ -927,8 +927,8 @@ void pci_register_bar(PCIDevice *pci_dev, int regio= n_num, > uint64_t wmask; > pcibus_t size =3D memory_region_size(memory); > =20 > - assert(region_num >=3D 0); > - assert(region_num < PCI_NUM_REGIONS); > + g_assert(region_num >=3D 0); > + g_assert(region_num < PCI_NUM_REGIONS); I must say, this is the strangest way I've ever heard of silencing a compiler warning. But if it works and my uneducated guess above about why is correct, Reviewed-by: Eric Blake 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. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --XAqw65qs5CKlKHCddCCIXkrrgpDt2OFFJ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVVQ5UAAoJEKeha0olJ0NqqJEH/jwG+uLfk03nTFSKRSHsgw0W d2ZNuMzUCIHqSyiu4vcA/5M5wKST3BH4yPOvKutsfuK3JvApiR1TTSIj6FBhXe+b 2L0AinHvntWt9LORHpd23CQN9veWVKGmsVotB5v2r8f/89aSNnSvlJhpMnP32cxo DTfTeNpbIm0kY7LmW4xnQoKUtmOVHp95BELJePi25o1xUIrhP0Mhd04dp1LatVpP G/5qa+hYpKLyhW4bQt2NUD94zekFst1gcKFXUI5Y97Lr316pa/sBdRcMO5Gi8S53 InYujOdXTf/yDEDwVfBxJm+Ow0YAbUgu56GVJdWfVr47KNw0mYVNiEiTeXYko5A= =3pJb -----END PGP SIGNATURE----- --XAqw65qs5CKlKHCddCCIXkrrgpDt2OFFJ--