[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] more questions due to MSVC warnings
From: |
Greg Chicares |
Subject: |
Re: [lmi] more questions due to MSVC warnings |
Date: |
Fri, 28 Mar 2008 12:20:29 +0000 |
User-agent: |
Thunderbird 2.0.0.12 (Windows/20080213) |
On 2008-03-25 00:13Z, Greg Chicares wrote:
>
> There are probably some places in ancient code where I left a
> local variable uninitialized, precisely in order to avoid a bogus
> borland warning about an unused initial value; now I would call
> that a bad workaround for a warning that would better have been
> suppressed. At the moment I can't think of a case where it would
> be preferable not to initialize a local at point of declaration.
Consider this code in 'test_main.cpp':
int result;
// GWC suppressed this because the borland compiler correcly warns
// that the initializing value is unused.
// int result = 0; // quiet compiler warnings
try
{
result = test_main( argc, argv );
Would you leave that alone, or revert the change flagged with my
initials and zero-initialize the variable explicitly? Probably we
don't care much about this particular snippet, but I'm trying to
formulate a general guideline that we can always follow without
ever thinking about it again.
The original line, including its comment:
// int result = 0; // quiet compiler warnings
was written by Beman Dawes, who would have had a good reason for
writing it that way.
[Looks like I didn't write "correctly" correctly.]