Please stop top-posting.
Kai Tietz writes:
>
> Richard Henderson <[EMAIL PROTECTED]>
> 08.03.2007 19:08
>
> > On Thu, Mar 08, 2007 at 06:06:57PM +0100, Kai Tietz wrote:
> > > > In gcc the file emutls.c assumes that a long has sizeof void * in
> > function
> > > > emutls_destroy.
> >
> > Not really. It assumes you can store the size of the array
> > in min(sizeof(long), sizeof(void*)) bytes.
> Just really ! The array arr has the type void ***, the cast happens on the
> first derefencing of arr. So the result remains a void **, which is for
> sure a pointer. This leads to a pointer truncation,
RTH is right. It isn't a pointer, it's an integer that has been
stored in a pointer. The pointer is not truncated, since it was never
a pointer in the first place. There is certainly no assumption that
long has sizeof void*, just that void* is large enough to hold the
length.
> therefore to a warning and a build failure. It is clear, that the first
> element of the array arr is in fact the integer value of a type with
> sizeof(void *).
> Wouldn't is better to have for this cast monster a structure. Something
> like
> struct sFieldArray {
> size_t count;
> void *arr[1];
> }
> ?
Andrew.