build failure with gcc 4.6.0 "array subscript is above array bounds"
David Laight
David.Laight at ACULAB.COM
Thu Aug 18 18:58:46 EST 2011
> Subject: build failure with gcc 4.6.0 "array subscript is
> above array bounds"
...
> That corresponds to:
> tmp = ((unsigned long *)child->thread.fpr)
> [TS_FPRWIDTH * (index - PT_FPR0)];
>
> child->thread.fpr is "double fpr[32][TS_FPRWIDTH]".
>
> index has already been bounds checked so we know it is <= PT_FPSCR.
That code looks gross....
I think it is trying to index a 2D array with a single index
and type-pun the lookup.
I'm not sure how the array size (for the subscript error)
is determined in the presence of the cast, but without
the cast the index would have to be less than 32.
I also suspect this is failing when gcc inlines the function
from a call where 'index' is a constant.
Possibly the code should read:
tmp = (unsigned long *)child->thread.fpr[index - PT_FPRO];
although index may have been scaled by 'sizeof double/sizeof long'.
David
More information about the Linuxppc-dev
mailing list