Subject: Re: alignment crash in v6 ipfilter when receiving on gif
To: None <port-sparc64@NetBSD.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: port-sparc64
Date: 07/17/2007 17:35:35
>>> +			 * 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;
> 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.

Right.  That's why it is not correct C.

It's fine for sparc64 because of the way the compiler we use on sparc64
works.  Pointers are "just memory addresses", and casting between two
pointer types is a no-op as far as generated code goes.  Provided you
don't actually try to access through an unaligned pointer, you can cast
any pointer type to any other as much as you like.

> Or am I missing something?  I am surprised that this works.

It's unwarranted chumminess with the compiler, I'd say.  But I'm
significantly more strict about such things than NetBSD is.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B