[MLton] cast-increases-required-alignment warnings
Stephen Weeks
sweeks@sweeks.com
Mon, 15 May 2006 20:10:48 -0700
I changed the typedef for "pointer" in util/pointer.h to be the same
as for "Pointer" from gen-types.c. That is, it is now
typedef unsigned char pointerAux __attribute__ ((aligned (4), may_alias));
typedef pointerAux* pointer;
Recompiling the runtime on Sparc/Solaris with this leaves only six of
the the "cast increases required alignment" warnings.
gc/generational.c:156: warning: cast increases required alignment of target type
gc/generational.c:180: warning: cast increases required alignment of target type
gc/generational.c:180: warning: cast increases required alignment of target type
gc/int-inf.c:360: warning: cast increases required alignment of target type
gc/int-inf.c:364: warning: cast increases required alignment of target type
basis/Real/modf.c:10: warning: cast increases required alignment of target type
I must have been mistaken in my earlier mail about the modf warning
being gone, since it's still there, and this change had no effect.
In any case, the remaining problems are hopefully solvable? The ones
in generational.c have to do with cardMap and crossMap.
s->generationalMaps.crossMap =
(GC_crossMapElem*)((pointer)s->generationalMaps.cardMap + cardMapSize);
GC_memcpy ((pointer)oldCrossMap, (pointer)s->generationalMaps.crossMap,
min (s->generationalMaps.crossMapLength * CROSS_MAP_ELEM_SIZE,
oldCrossMapSize));
Maybe it really is time for a couple of union types, e.g. defining
cardMap (crossMap) as a union of pointer and GC_cardMapElem*
(GC_crossMapElem*)?
Here are the offending lines in int-inf.c
setFrontier (&gcState, (pointer)(&sp->chars[size]), bytes);
return pointerToObjptr ((pointer)&sp->chars, gcState.heap.start);
I'm not sure how to quell the warnings, since the correctness seems to
depend on the fact that sp->chars is 4-byte aligned and size = 0 mod
4. Perhaps the second warning (and part of the first) can be solved
by a better definition of the GC_string8 type?