https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109990

--- Comment #4 from Bruno Haible <bruno at clisp dot org> ---
> > 
> >                   char *new_pool = (char *) realloc (string_space, 
> > new_size);
> >                   if (new_pool == ((void *)0))
> >                     goto out;
> >                   if (__builtin_expect (string_space != new_pool, 0))
> >                     {
> >                       size_t i;
> >                       for (i = 0; i < nmap; i++)
> >                         {
> >                           map[i].alias += new_pool - string_space;
> >                           map[i].value += new_pool - string_space;
> >                         }
> >                     }
> >                   string_space = new_pool;

> Also I think `new_pool - string_space` is undefined really.  That is
> subtracting two unrelated arrays is undefined. You can only compare equality
> on them.

That is the only way of keeping track of pointers _into_ the string_space area,
when it is reallocated. How else would you want to do it?

Reply via email to