lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] more questions due to MSVC warnings


From: Vadim Zeitlin
Subject: [lmi] more questions due to MSVC warnings
Date: Mon, 24 Mar 2008 19:21:37 +0100

 Hello again,

 There is another code which results in MSVC warnings ("local variable
may be used without having been initialized" this time) that I don't really
know how to fix but which might indicate a problem. This is in
interest_rates.cpp, in the function called convert_interest_rates(). There
the cached_{monthly,annual}_net_rate variables may not be set during the
first loop iteration) or changed (during the subsequent ones) if the
condition in the if at lines 215..219 is false. But they're assigned to the
elements of {monthly,annual}_net_rate in any case. Again, I don't know if
this is a real problem or if the condition is always true or if it doesn't
matter what we assign to these arrays in the case it is false but it would
seem that these assignments should be inside the if statement, not outside
it. What do you think?

 I'd also like to know how to deal with the same warning when it definitely
does _not_ indicate a problem, like in stream_cast() function in the header
with the same name. There the "result" variable will only be returned if it
was successfully initialized (by reading it from the stream) but the
compiler doesn't realize this and still warns about it being potentially
uninitialized. I think it would be worth to add " = To()" to the variable
declaration just to suppress this warning as I'd like to keep it enabled
globally because it can help to discover real bugs sometimes (whether the
problem in interest_rates.cpp is real or not). Would you agree with this?

 Thanks,
VZ





reply via email to

[Prev in Thread] Current Thread [Next in Thread]