[PATCH] fix #19444 - build failures with -O1 due to -Wmaybe-uninitialized

Martin Sebor msebor@gmail.com
Wed Jan 13 17:02:00 GMT 2016


The Glibc FAQ on the Wiki documents the limitation that the library
prevents users from building it without optimization (-O0).  However,
the mechanism in place doesn't prevent using -O1, and the FAQ doesn't
mention that this level cannot or should not be used.  Using a lower
level of optimization than -O2 can be helpful in debugging.

However, trunk fails to build with -O1 due to a number of warnings
about possibly uninitialized that are treated as errors.  It turns
out that the warnings are false positives caused by a documented
limitation of the GCC implementation (the value range propagation
optimization is disabled at -O1, which prevents GCC from seeing
that in some of the non-trivial cases of apparently uninitialized
variables the variables are in fact initialized when used).

In his comments on the bug, Carlos suggests to fix these instances
of false positives and to get -O1 to work.  The attached patch
does just that.  In the patch, to minimize the impact of the
(otherwise unnecessary) initialization, rather than initializing
them for all the code paths, I reduced the scope of the local
variables that are subject to the warning and added the redundant
initialization only for the problem code paths.  This led to more
changes that would otherwise be required but resulted in code
that's easier to follow.

The patch also adds -Wno-error=maybe-uninitialized to the warning
options when -O1 or lower is set in CFLAGS to prevent these false
positives from causing build failures.  This change renders the
changes above strictly unnecessary.  I include both since I think
both are worthwhile but I can remove one or the other if others
have a different preference.

Tested on x86_64.

Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: glibc-19444.patch
Type: text/x-patch
Size: 6694 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20160113/58b63959/attachment.bin>


More information about the Libc-alpha mailing list