This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] growing regno_reg_rtx


> It appears to me that the zeroing of the newly allocated part of
> regno_reg_rtx starts at the wrong place.  I think the end of the previous
> storage is found at "old_size * sizeof (rtx)" from the reallocated space,
> rather than "old_size", since sizeof(rtx) != 1.
>
>       new1 = (rtx *) ggc_realloc (f->emit->x_regno_reg_rtx,
> 				  old_size * 2 * sizeof (rtx));
>-      memset (new1 + old_size, 0, old_size * sizeof (rtx));
>+      memset (new1 + (old_size * sizeof (rtx)), 0, old_size * sizeof
(rtx));

The code was right.  Since new1 is an rtx*, summing old_size automagically
multiplies it by sizeof(rtx). new1 + old_size is the same as
&new1[old_size], which clearly does the multiplication.

Paolo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]