[MLton] Port to HP-UX

Stephen Weeks MLton@mlton.org
Mon, 24 Apr 2006 14:47:27 -0700


Ville, I've committed your patch (modulo some alphabetization and tab
removal).

> I'm still getting warnings like this:
> 
> gc.c:628: warning: dereferencing type-punned pointer will break strict-aliasing rules
> gc.c:629: warning: dereferencing type-punned pointer will break strict-aliasing rules
> gc.c:630: warning: dereferencing type-punned pointer will break strict-aliasing rules
> gc.c:631: warning: dereferencing type-punned pointer will break strict-aliasing rules
> 
> I just noticed I don't get these on Linux.  The Makefile for runtime
> uses -fno-strict-aliasing on certain files.  Should it be added for
> gc.c on HP-UX?

Here are the offending four lines from gc.c

  maybeCall (f, s, (pointer*)&s->callFromCHandler);
  maybeCall (f, s, (pointer*)&s->currentThread);
  maybeCall (f, s, (pointer*)&s->savedThread);
  maybeCall (f, s, (pointer*)&s->signalHandler);

The offending four fields of s, which is of type GC_state, are all of
type GC_thread, declared in gc.h with a typedef:

  typedef struct GC_thread {
  ... struct fields omitted ...
  } *GC_thread;

So, it looks like we're relying on the fact that a pointer to a
GC_thread can be treated as a pointer to a "pointer", where "pointer"
is a typedef for char*.  I don't know of a better way in C to code
what we want so that we don't get the warning.  I would be happy for
a C wizard reading this list to tell us one.  If not, I'm fine with
adding the -fno-strict-aliasing (perhaps it should be added
irrespective of platform?).