[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] careadlinkat: fix GCC 10 workaround
From: |
Bernhard Voelker |
Subject: |
Re: [PATCH] careadlinkat: fix GCC 10 workaround |
Date: |
Mon, 17 Aug 2020 16:40:50 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 |
Hi Paul,
On 2020-05-11 19:47, Paul Eggert wrote:
> +2020-05-11 Paul Eggert <eggert@cs.ucla.edu>
> +
> + careadlinkat: fix GCC 10 workaround
> + * lib/careadlinkat.c (careadlinkat) [GCC_LINT]:
> + Massage the code so that it’s closer to what it was before
> + the GCC 10.1.0 workaround was introduced. This fixes
> + a loop when !buffer and the bug workaround is in effect.
> + Remove unnecessary casts. Defend in a different way
> + against (buffer && !buffer_size), by adding at least 1
> + to buf_size each time through the loop.
GCC-10.2.1 (which I have here on Tumbleweed) still complains:
$ ./gnulib-tool --create-testdir --dir=/tmp/testdir careadlinkat
$ cd /tmp/testdir && ./configure && make
...
gcc -DHAVE_CONFIG_H -I. -I.. -DGNULIB_STRICT_CHECKING=1 -g -O2 -MT
careadlinkat.o -MD -MP -MF \
.deps/careadlinkat.Tpo -c -o careadlinkat.o careadlinkat.c
careadlinkat.c: In function 'careadlinkat':
cc1: warning: function may return address of local variable
[-Wreturn-local-addr]
careadlinkat.c:73:8: note: declared here
73 | char stack_buf[1024];
| ^~~~~~~~~
And there doesn't seem to be any activity on the GCC bug and related ones.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95044
Currently, we can only get avoid the warning via GCC_LINT.
Do you have another idea how to avoid it? E.g. referencing
static memory instead of stack memory?
Thanks & have a nice day,
Berny
- Re: [PATCH] careadlinkat: fix GCC 10 workaround,
Bernhard Voelker <=