Subject: Re: alignment crash in v6 ipfilter when receiving on gif
To: None <port-sparc64@NetBSD.org>
From: Pavel Cahyna <pavel@NetBSD.org>
List: port-sparc64
Date: 07/17/2007 23:14:41
On Tue, Jul 17, 2007 at 11:26:36AM -0400, der Mouse wrote:
> > +			/*
> > +			 * XXX cast to i6addr_t is unsafe because it
> > +			 * presumes void * alignment which may not be
> > +			 * true, but IP6_NEQ casts to u_32_t.
> > +			 */
> 
> While this is fine for sparc64, and I think is OK for all architectures
> NetBSD supports, it is not correct C; converting to i6addr_t * may lose
> information, which of course cannot be recovered by casting back to
> some other type.
> 
> Why cast to i6addr_t * at all, when IP6_NEQ casts immediately anyway?

How is it fine for sparc64? Converting to i6addr_t * tells the compiler
that it is possible to assume 64-bit alignment, which is wrong in this
situation. Or am I missing something? I am surprised that this works.

Pavel