When trying to compile elfutils version 0.143 on x86_64 Arch Linux using GCC
4.4.1 or 4.4.2 with options -mtune=k8 -O3, I get the following output:
gcc -D_GNU_SOURCE -DHAVE_CONFIG_H -DIS_LIBDW -I. -I.. -I. -I. -I./../libelf
-I.. -I./../lib -Wall -Werror -Wshadow -Wunused -Wformat=2 -Wextra
-std=gnu99 -mtune=k8 -fstack-protector -O3 -pipe -MT dwarf_getcfi_elf.o -MD -MP
-MF .deps/dwarf_getcfi_elf.Tpo -c -o dwarf_getcfi_elf.o dwarf_getcfi_elf.c
cc1: warnings being treated as errors
dwarf_getcfi_elf.c: In function dwarf_getcfi_elf:
dwarf_getcfi_elf.c:164: error: search_table_entries may be used uninitialized
in this function
dwarf_getcfi_elf.c:164: note: search_table_entries was declared here
dwarf_getcfi_elf.c:165: error: search_table_encoding may be used
uninitialized in this function
dwarf_getcfi_elf.c:165: note: search_table_encoding was declared here
This seems to happen with every AMD-related tune option (-mtune=k8, -march=k8,
-march=athlon64, -march=amdfam10 etc) when used with -O3.
The offending code from dwarf_getcfi_elf.c follows:
146:static Dwarf_CFI *
147:getcfi_gnu_eh_frame (Elf *elf, const GElf_Ehdr *ehdr, const GElf_Phdr
*phdr)
148:{
149: if (unlikely (phdr->p_filesz < 4))
150: goto invalid;
151:
152: Elf_Data *data = elf_getdata_rawchunk (elf, phdr->p_offset,
phdr->p_filesz,
153: ELF_T_BYTE);
154: if (data == NULL)
155: {
156: invalid_hdr:
157: invalid:
158: /* XXX might be read error or corrupt phdr */
159: __libdw_seterrno (DWARF_E_INVALID_CFI);
160: return NULL;
161: }
162:
163: Dwarf_Addr eh_frame_ptr;
164: size_t search_table_entries;
165: uint8_t search_table_encoding;
166: const uint8_t *search_table = parse_eh_frame_hdr (data->d_buf,
phdr->p_filesz,
167: phdr->p_vaddr, ehdr,
168: &eh_frame_ptr,
169: &search_table_entries,
170: &search_table_encoding);
----
gcc -v:
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --prefix=/usr --enable-shared
--enable-languages=c,c++,fortran,objc,obj-c++,ada --enable-threads=posix
--mandir=/usr/share/man --infodir=/usr/share/info --enable-__cxa_atexit
--disable-multilib --libdir=/usr/lib --libexecdir=/usr/lib --enable-clocale=gnu
--disable-libstdcxx-pch --with-tune=generic
Thread model: posix
gcc version 4.4.2 (GCC)
The elfutils source can be downloaded from:
https://fedorahosted.org/releases/e/l/elfutils/
--
Summary: elfutils triggers bogus "may be uninitialized" with -O3
-mtune=k8
Product: gcc
Version: 4.4.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: marti at juffo dot org
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41817