[Bug general/21011] "may be used uninitialized" error with -Werror=maybe-uninitialized

mark at klomp dot org sourceware-bugzilla@sourceware.org
Wed Apr 19 15:14:00 GMT 2017


https://sourceware.org/bugzilla/show_bug.cgi?id=21011

--- Comment #11 from Mark Wielaard <mark at klomp dot org> ---
So the flag that seem to trigger it is -Os (but only on 32bit systems?).
Proposed the following:

commit 7114c513fbebcca8b76796b7f64b57447ba383e1
Author: Mark Wielaard <mark@klomp.org>
Date:   Wed Apr 19 17:07:46 2017 +0200

    libelf: Initialize n to zero in elf_getarsym.

    When building with gcc -Os it seems we can inline read_number_entries
    but if that function fails then n will not be initialized. GCC seems not
    to realize that in that case n won't be used at all. Explicitly initialize
    n to zero to prevent a spurious error: 'n' may be used uninitialized in
    this function [-Werror=maybe-uninitialized] in that case.

    https://sourceware.org/bugzilla/show_bug.cgi?id=21011

    Signed-off-by: Mark Wielaard <mark@klomp.org>

https://sourceware.org/ml/elfutils-devel/2017-q2/msg00042.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Elfutils-devel mailing list