More on Ptr types

Manuel M. T. Chakravarty chak at
Fri Jun 14 05:33:08 EDT 2002

George Russell <ger at> wrote,

> By the way, you lot are aware that under the old ANSI C
> standard at least, pointer types can have different sizes
> depending on the type?  Thus a pointer to a
> properly-aligned 64-bit entity needs 3 less bits than one
> to an 8-bit entity, and implementations are entitled to
> use this.  The only guarantee I can remember is that (void
> *) is big enough to represent everything.  Does this
> affect things at all?

I have noticed that, but I don't think we should care about
this in the FFI spec.  There are two possible scenarios:

* An architecture just doesn't use all address bits for all
  memeory areas, but stores addresses in a uniform word
  size.  No problem as long as we don't scramble these
  bits.  The FFI never requires to scramble such bits, so it
  is on the implementation to get this right.

* An architecture really stores such pointers in differently
  sized objects and passes them around like this.  As we
  can't really distinguish these pointers reliably in
  Haskell, all sorts of things, like all the methods in the
  class Storable break and I don't see any halfway easy way
  to prevent this by changing the spec.  Anybody know an
  example of such an architecture?


More information about the FFI mailing list