This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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

On Wed, 13 Jan 2016, Martin Sebor wrote:

> 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.

In general, we want to avoid unnecessary initializations.  I'd prefer 
adding a default case to the relevant switch statements that calls 
__builtin_unreachable (with a comment explaining why it's unreachable, and 
that when VRP is disabled spurious uninitialized warnings occur without 
the __builtin_unreachable call).

> The patch also adds -Wno-error=maybe-uninitialized to the warning
> options when -O1 or lower is set in CFLAGS to prevent these false

In general, we want to avoid -Wno- options, only adding them if the issue 
can't be fixed in the code (e.g. for code imported verbatim from 
elsewhere, or for testcases whose purpose is to test what the library does 
for a dubious usage that GCC warns about, such as the fortification tests, 
and where the diagnostic control pragmas can't be used for some reason).  
And we want to migrate existing -Wno- options to source fixes / uses of 
DIAG_* macros where possible.

That is, I think we should fix only the sources, without a makefile 
change, and should fix the sources using __builtin_unreachable calls.

(I agree that -O1 and -Os builds ought to work without any extra build or 
test failures, and preferably -O0 should work except for the specific 
files requiring optimization.)

Joseph S. Myers

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]