Subject: Re: NetBSD/pdp10 ?
To: None <port-vax@netbsd.org, tech-kern@netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 03/06/2002 22:33:15
>> I've often considered building a gcc variant that deliberately
>> breaks a bunch of the sloppy assumptions people make - like that all
>> pointers are the same size, or that
>> *(foo **)&bar_ptr == (foo *)bar_ptr....

> i think you better explain this last one to us peons...

It amounts to the "all pointers are just memory addresses" assumption,
that the bits making up a pointer pointing to a specific piece of
memory are the same regardless of what type that piece of memory is
considered as being.  ISTR hearing of a C compiler for the Lisp Machine
that implemented pointers as <array,index> pairs; the above assumption
breaks badly in the face of such an implementation.  (They had some
interesting tricks to fulfil the promises that _are_ made about when
you can cast pointers and get working results....)

Another possible case where the assumption I wrote above fails is if
pointers carry type information as well as address information.  Then
casting would, among other things, change the type bits, but the
left-hand side of what I wrote above would result in a pointer that has
one type according to C but a different type according to the type
bits.

If I wanted to break it for the sake of breaking it on a machine that
would "normally" represent pointers as just memory addresses, I would
compute a hash value for every type, and offset all pointers to that
type by the type's hash value.  (A pointer conversion would then
involve adding the difference between the two types' hash values.)
(I'm not sure what I'd do about pointers to incomplete types, but I'm
sure something could be worked out.)

/~\ 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