[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gcc10's -Wreturn-local-addr gives FP warning about lib/careadlinkat
From: |
Kaz Kylheku (Coreutils) |
Subject: |
Re: gcc10's -Wreturn-local-addr gives FP warning about lib/careadlinkat |
Date: |
Thu, 06 Feb 2020 08:12:54 -0800 |
User-agent: |
Roundcube Webmail/0.9.2 |
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;
}
Re: gcc10's -Wreturn-local-addr gives FP warning about lib/careadlinkat,
Kaz Kylheku (Coreutils) <=