This is the mail archive of the libc-alpha@sourceware.org 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: Fix -Wmaybe-uninitialized warning in xdr.c


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


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