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

--- Comment #9 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> ---
Note, however, that there is a small regression in GCC 11: the warning for t is
output as expected, but if -fsanitize=undefined is given, the message for t is
suboptimal, saying "*&t[0]" instead of "t[0]":

zira:~> gcc-11 -Wmaybe-uninitialized -O2 -c tst.c -fsanitize=undefined
tst.c: In function ‘foo’:
tst.c:12:15: warning: ‘*&t[0]’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
   12 |   return t[0] + u[0];
      |          ~~~~~^~~~~~
tst.c:12:15: warning: ‘u[0]’ may be used uninitialized in this function
[-Wmaybe-uninitialized]

No such issue without -fsanitize=undefined:

zira:~> gcc-11 -Wmaybe-uninitialized -O2 -c tst.c
tst.c: In function ‘foo’:
tst.c:12:15: warning: ‘u[0]’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
   12 |   return t[0] + u[0];
      |          ~~~~~^~~~~~
tst.c:12:15: warning: ‘t[0]’ may be used uninitialized in this function
[-Wmaybe-uninitialized]

It is impossible to say whether this is fixed in GCC 12 and later, because of
PR 110896, i.e. the warning is always missing.

Reply via email to