This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: get_ref_base_and_extent() semantics
On Fri, Dec 12, 2008 at 03:05:32PM +0100, Martin Jambor wrote:
> In this particular case, the ofset of var_array + its max_size (the
> size of its element, as the function computes it, this is something I
> also do not really understand)
No, it's not the element size, it's the size of the whole array, I got
this mixed up. The actual calculation is:
tree asize = TYPE_SIZE (TREE_TYPE (TREE_OPERAND (exp, 0)));
/* We need to adjust maxsize to the whole array bitsize.
But we can subtract any constant offset seen so far,
because that would get us outside of the array otherwise. */
if (maxsize != -1 && asize && host_integerp (asize, 1))
maxsize = TREE_INT_CST_LOW (asize) - bit_offset;
else
maxsize = -1;
It therefore definitely takes the size of the whole array, I still
don't quite understand why bit_offset is subtracted though since it
contains the offset of the array itself, not anything within the
array... at least if I understand the code correctly.
(Meanwhile, I'm preparing a patch to be conservative if both variable
indices and unions were seen.)
Thanks,
Martin