https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104060
Bug ID: 104060 Summary: -Wmaybe-uninitialized false alarm on address of local array Product: gcc Version: 11.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: eggert at cs dot ucla.edu Target Milestone: --- Created attachment 52209 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52209&action=edit compile with 'gcc -Wuninitialized' to see the false alarm I ran into this problem when compiling an experimental version of GNU coreutils with gcc 11.2.1 20211203 (Red Hat 11.2.1-7), x86-64. This is a regression, since gcc 8.5.0 20210514 (Red Hat 8.5.0-4) does not have the problem. Compile the attached program with 'gcc -Wuninitialized -S false-alarm-uninit.c'. There should be no output, but GCC outputs the following. The diagnostic is incorrect, as bin_buffer_unaligned is an array that is never read from or written to. Apparently GCC is getting confused because the array's address is taken (but that address is never dereferenced). false-alarm-uninit.c: In function ‘digest_check’: false-alarm-uninit.c:13:31: warning: ‘bin_buffer_unaligned’ may be used uninitialized [-Wmaybe-uninitialized] 13 | unsigned char *bin_buffer = ptr_align (bin_buffer_unaligned, 1024); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ false-alarm-uninit.c:2:1: note: by argument 1 of type ‘const void *’ to ‘ptr_align’ declared here 2 | ptr_align (void const *ptr, unsigned long alignment) | ^~~~~~~~~ false-alarm-uninit.c:12:17: note: ‘bin_buffer_unaligned’ declared here 12 | unsigned char bin_buffer_unaligned[10000]; | ^~~~~~~~~~~~~~~~~~~~