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: [PATCH] ggc-page loop


On Tue, May 2, 2017 at 3:41 PM, Nathan Sidwell <nathan@acm.org> wrote:
> This loop in ggc-page confused me, because the iterator is one greater than
> the indexing value.  Also the formatting of the array indexing is incorrect.
>
> Fixed thusly, and applied as obvious after booting on x86_64-linux-gnu

-  for (i = G.by_depth_in_use; i > 0; --i)
+  for (unsigned i = G.by_depth_in_use; i--;)
     {
-      page_entry *p = G.by_depth[i-1];
-      p->index_by_depth = i-1;
+      page_entry *p = G.by_depth[i];
+      p->index_by_depth = i;
     }

I think this is still incorrect.  you replaced i - 1 by i but did not
start at G.by_depth_in_use - 1;

Thanks,
Andrew


>
> nathan
> --
> Nathan Sidwell


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