On 2020-02-05 16:27, Jim Meyering wrote:
Building latest latest coreutils using latest-from-git gcc10 evokes
this false positive:

lib/careadlinkat.c: In function 'careadlinkat':
cc1: error: function may return address of local variable
[-Werror=return-local-addr]
lib/careadlinkat.c:73:8: note: declared here
   73 |   char stack_buf[1024];

I'm guessing improved flow analysis will eventually suppress this.

By chance, does this make it go away away (my changes in #else parts of #ifdef)?

      if (link_size < buf_size)
        {
          buf[link_size++] = '\0';

          if (buf == stack_buf)
            {
              char *b = (char *) alloc->allocate (link_size);
              buf_size = link_size;
              if (! b)
                break;
              memcpy (b, buf, link_size);
#ifdef OLD
              buf = b;
#else
              return b;
#endif
            }
else if (link_size < buf_size && buf != buffer && alloc->reallocate)
            {
              /* Shrink BUF before returning it.  */
              char *b = (char *) alloc->reallocate (buf, link_size);
#ifdef OLD
              if (b)
                buf = b;
#else
              if (b)
                return b;
#endif
            }

          return buf;
        }



Reply via email to