On 2023/08/03 23:23, Valery Ushakov wrote:
On Thu, Aug 03, 2023 at 13:33:27 +0000, Rin Okuyama wrote:

-Wuse-after-free for GCC 12 is premature. It fires on a common idiom:

        newbuf = realloc(buf, size);
        p = newbuf + (p - buf);

Let shut this up for GCC 12 (with hoping it gets improved for 13!).

C99 says

        J.2  Undefined behavior

        [#1]   The   behavior   is   undefined   in   the  following
        circumstances:
[...]
          -- The  value of a pointer to an object whose lifetime has
             ended is used (6.2.4).


Yes, for the "obvious" implementation of pointers as addresses the
above idiom happens to work, but it doesn't make that idiom any less
UB.

Ah, I only thought about "obvious" impl. Thank you for kind
explanation! I will revert them for now.

Thanks,
rin

Reply via email to