https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99797
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |WONTFIX
Status|UNCONFIRMED |RESOLVED
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>Ideally, I think GCC should reject code when it is clearly UB (address not
>taken).
It can't because it is only undefined at runtime which means if it is never
invoked the undefined behavior will never been seen.
GCC does warn with -Wall which should be good enough for this case:
apinski@xeond:~$ ~/upstream-gcc/bin/gcc -Wall t77.c -O2 -S
t77.c: In function ‘foo’:
t77.c:9:8: warning: ‘c’ is used uninitialized [-Wuninitialized]
9 | if (!c)
| ^
>Still when taking the address of 'c' the code is not UB
NO it is still undefined.