Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Feb 2006 00:34:28 -0800
From:      Colin Percival <cperciva@freebsd.org>
To:        Giorgos Keramidas <keramida@ceid.upatras.gr>
Cc:        arch@freebsd.org, stefanf@freebsd.org, des@des.no
Subject:   Re: [releng_6 tinderbox] failure on sparc64/sparc64
Message-ID:  <43F04494.4030900@freebsd.org>
In-Reply-To: <20060213082129.GA13997@flame.pc>
References:  <20060205084813.GN21806@wombat.fafoe.narf.at> <867j89n71d.fsf@xps.des.no> <20060205220211.GA5151@falcon.midgard.homeip.net> <20060213.002310.125802352.imp@bsdimp.com> <20060213082129.GA13997@flame.pc>

next in thread | previous in thread | raw e-mail | index | archive | help
Giorgos Keramidas wrote:
> On 2006-02-13 00:23, "M. Warner Losh" <imp@bsdimp.com> wrote:
>> 	struct foo foo;
>> 	uint32_t value[sizeof(foo) / sizeof(uint32_t)];
>>
>> 	memcpy(value, &foo);
>> 	// write out value one 32-bit word at a time
>>
>> Is that right?  Or at least 'proper' here means defined.
> 
> AFAIK, yes.

I agree that the behaviour of the above code is defined, but
I'd be much happier if value[] was defined to be an array of
length ((sizeof(foo) - 1) / sizeof(uint32_t) + 1), just in
case sizeof(foo) happens to not be a multiple of 4.  :-)

Colin Percival




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?43F04494.4030900>