This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Fix -Wmaybe-uninitialized warning in xdr.c
- From: Roland McGrath <roland at hack dot frob dot com>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Wed, 9 Jul 2014 12:39:45 -0700 (PDT)
- Subject: Re: Fix -Wmaybe-uninitialized warning in xdr.c
- Authentication-results: sourceware.org; auth=none
- References: <20140708175919 dot GL609 at spoyarek dot pnq dot redhat dot com>
This is fine in this case (and I noticed you already committed it). But
I'll point out that in the past the policy was explicitly not to make this
sort of change. That is, when a change is necessary to suppress some
compiler warning, but the change results in worse code (here, a dead
store), then we favor optimal code over warning-free code. Sometimes the
source code can be rejiggered such that the generated code is the same (or
better) but the compiler groks it better and doesn't generate the bogus
warning. Sometimes that's impossible and we just have to accept that we
are smarter than the compiler is.
Nowadays, we probably want to use a balancing test of the performance vs
the ease-of-maintenance improvement of eliminating warnings. It seems
almost certain that we don't care about the cost of the dead store in
xdr_string. But IMHO it should always be an explicit decision to trade off
after careful consideration of the particular case. It should never be a
default-OK to pessimize the code to work around the compiler's lack of
intelligence. Certainly any change made for that reason should have
comments saying that the initialization is not actually desirable but was
added to silence a compiler warning.
Thanks,
Roland