[Bug middle-end/109990] [12/13/14 Regression] Bogus -Wuse-after-free warning after realloc
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri May 26 14:31:47 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109990
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> ```
>
> 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;
> ```
>
> Hmmm
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.
More information about the Gcc-bugs
mailing list