https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81897

--- Comment #18 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
(In reply to Arnd Bergmann from comment #16)
> Created attachment 43056 [details]
> linux/net/ipv6/route.c, preprocessed and compressed
> 
> To test the patch, I reverted the workaround that was added to the kernel
> when I originally reported this. Unfortunately the warning is still there,
> only the reduced version is fixed. I attached the preprocessed source now,
> test with
> 
> $ x86_64-linux-gcc-8.0.0 -fno-strict-aliasing -Wall -O2 -Wno-pointer-sign -c
> route-1.i
> /git/arm-soc/net/ipv6/route.c: In function 'inet6_rtm_getroute':
> /git/arm-soc/net/ipv6/route.c:4350:9: warning: 'dst' may be used
> uninitialized in this function [-Wmaybe-uninitialized]
>    goto errout;
>          ^~~~~~
>   }
> 
> Reducing this with the latest gcc-8.0.0 snapshot gave me
> 
> enum { true } fn1();
> int inet6_rtm_getroute_iif, inet6_rtm_getroute_rt, inet6_rtm_getroute_rtm_0;
> int *inet6_rtm_getroute___trans_tmp_8;
> int fn2();
> void fn3() {
>   int *dst;
>   _Bool fibmatch = inet6_rtm_getroute_rtm_0 & 2;
>   if (inet6_rtm_getroute_iif) {
>     if (!fibmatch)
>       dst = inet6_rtm_getroute___trans_tmp_8;
>     static _Bool __warned;
>     fn2() && __warned &&fn1();
>     __warned = true;
>   } else if (!fibmatch)
>     dst = 0;
>   if (fibmatch)
>     dst = 0;
>   inet6_rtm_getroute_rt = *dst;
> }

For both the reduced and full testcase in comment #16, I see this warning
present in GCC 5, 6, 7, and 8 (mainline).  So this does not look like a
regression in the recent past.

I also tested the reduced case in this comment for gcc4.5 (at least at
r150051), and the warning is present there as well.  I didn't test the full
testcase, as they were other warnings that muddled the waters in such ancient
version.

If you feel this reduced case is still problematic, I think we should open a
new PR, and mark it as a regression if you find a GCC far enough back that does
not exhibit the warning.  If you can't find a GCC for which this has regressed,
then at least mark it as an enhancement request.

Reply via email to