From owner-freebsd-arch@FreeBSD.ORG Sun Feb 5 22:02:13 2006 Return-Path: X-Original-To: arch@FreeBSD.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C3ABF16A422 for ; Sun, 5 Feb 2006 22:02:13 +0000 (GMT) (envelope-from ertr1013@student.uu.se) Received: from pne-smtpout1-sn2.hy.skanova.net (pne-smtpout1-sn2.hy.skanova.net [81.228.8.83]) by mx1.FreeBSD.org (Postfix) with ESMTP id 04B9E43D48 for ; Sun, 5 Feb 2006 22:02:12 +0000 (GMT) (envelope-from ertr1013@student.uu.se) Received: from falcon.midgard.homeip.net (83.253.29.241) by pne-smtpout1-sn2.hy.skanova.net (7.2.070) id 43E2F55D000C88A6 for arch@FreeBSD.org; Sun, 5 Feb 2006 23:02:12 +0100 Received: (qmail 5226 invoked by uid 1001); 5 Feb 2006 23:02:11 +0100 Date: Sun, 5 Feb 2006 23:02:11 +0100 From: Erik Trulsson To: Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= Message-ID: <20060205220211.GA5151@falcon.midgard.homeip.net> Mail-Followup-To: Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= , Stefan Farfeleder , arch@FreeBSD.org References: <20060204211357.GD7604@ip.net.ua> <20060204.143353.109955782.imp@bsdimp.com> <86fymyn5il.fsf@xps.des.no> <20060204.155856.39766510.imp@bsdimp.com> <20060205084813.GN21806@wombat.fafoe.narf.at> <867j89n71d.fsf@xps.des.no> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <867j89n71d.fsf@xps.des.no> User-Agent: Mutt/1.5.11 Cc: arch@FreeBSD.org, Stefan Farfeleder Subject: Re: [releng_6 tinderbox] failure on sparc64/sparc64 X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Feb 2006 22:02:13 -0000 On Sun, Feb 05, 2006 at 04:45:34PM +0100, Dag-Erling Sm=F8rgrav wrote: > Stefan Farfeleder writes: > > On Sat, Feb 04, 2006 at 03:58:56PM -0700, M. Warner Losh wrote: > > > This driver wants to access these structures as arrays of uint32_t. > > > It used to cast directly, but that isn't allowed. So, I've passed > > > the cast through a (void *). Is that allowed? Eg: > > >=20 > > > struct foo foo; > > > ((uint32_t *)(void *)&foo)[3] =3D 12; > > >=20 > > > is that OK? > > I'm afraid that only silences the warning without solving the underlying > > problem. I don't think there's a Standard conforming way to treat a > > struct foo as an uint32_t array. >=20 > A union should do the trick. No, it will not. If you have a struct foo and try to access it as an array of int, the program will have unspecified (and maybe even undefined) behaviour. It does not matter if you do it with a union or by casting pointers. In general, if you have an object of type X, then the only ways it can be accessed is either as an object of type X, or as an array of [unsigned] char. =20 --=20 Erik Trulsson ertr1013@student.uu.se