[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Shutting up warnings

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: 2005-11-22 02:29:34 CET

Peter N. Lundblad wrote:
> On Mon, 21 Nov 2005, Julian Foad wrote:
>>Peter, for my interest, could you show me a few warnings of this type from gcc
>>4.0.2? I'd like to have a look at our code in those places, and try to see how
>>it differs.
> Here we go. The problem seems to be that if you pass a variable by
> reference to a function whihc is expected to fill in the variable value,
> the compiler is pesimistic about this.

Thanks. Yes, that seems to be what's new in GCC 4. GCC 3's "-Wuninitialized"
option doesn't act on variables addressed by reference (or structures, or
various other things).

> I can go fixing these if people
> don't object. I'm not opposed to shutting up warnings per se. I more want
> us to resolve the question before going on and doing this in particular
> cases.

I think it would definitely be wrong to initialise these variables just to
avoid the warnings. It would be illogical since they are always being
initialised by the existing code, and it could hide genuine errors as has been
pointed out before.

This is clearly the kind of warning that is suitable only for occasional use
(when somebody feels like checking all of the reported possible problems), or
perhaps for use on code where output parameters are specially marked so the
compiler knows that's what they are. Just like the "Function argument is
unused" warning that was discussed a few weeks ago.

The same applies in theory to the case that I just told Eric he should "fix".
(What's the word I need? "Indulge the compiler"?) I think I have just made up
my mind that we should _not_ generally add code just to avoid these speculative
kinds of warnings. Erik's particular case was the only remaining instance of a
particular kind, so the benefit-to-clutter ratio was high. (I imagined several
instances of that kind had existed and been "fixed", but I'm not sure.)

- Julian

> ../1.3.x/subversion/libsvn_delta/svndiff.c: In function 'decode_window':
> ../1.3.x/subversion/libsvn_delta/svndiff.c:339: warning: 'op.action_code' may be used uninitialized in this function
> ../1.3.x/subversion/libsvn_delta/svndiff.c:339: warning: 'op.offset' may be used uninitialized in this function
> ../1.3.x/subversion/libsvn_delta/svndiff.c:411: warning: 'ninst' may be used uninitialized in this function

To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Nov 22 02:30:19 2005

This is an archived mail posted to the Subversion Dev mailing list.