|
From: Luigi B. <lui...@gm...> - 2009-11-27 11:31:52
|
On Fri, 2009-11-27 at 12:15 +0100, Ferdinando Ametrano wrote:
> warning C4701: potentially uninitialized local variable 'ex'
> used c:\projects\quantlib\trunk\quantlib\ql\pricingengines\vanilla\analyticgjrgarchengine.cpp 268
> warning C4701: potentially uninitialized local variable 'k3'
> used c:\projects\quantlib\trunk\quantlib\ql\pricingengines\vanilla\analyticgjrgarchengine.cpp 279
> warning C4701: potentially uninitialized local variable 'k4'
> used c:\projects\quantlib\trunk\quantlib\ql\pricingengines\vanilla\analyticgjrgarchengine.cpp 279
> warning C4701: potentially uninitialized local variable 'sigma'
> used c:\projects\quantlib\trunk\quantlib\ql\pricingengines\vanilla\analyticgjrgarchengine.cpp 267
>
> using potentially uninitialized local variables smells like a genuine bug to me
Yes--in your compiler's branch detection algorithm :)
The variables above are all initialized one way or the other in a
section of code that reads:
if (init_ != true || constants_match != true || ...) {
... the variables are initialized to some values ...
}
else if (init_ == true && constants_match == true) {
... the variables are initialized to some other values ...
}
My guess is that since a final "else" is missing, the compiler doesn't
realize that between them the two conditions cover all possible cases.
Of course the if could be rewritten so that the warning disappears,
though---the "else if" could just be an "else" (and of course, the
"init_ != true" and "init_ == true" should be just "!init_" and
"init_"...)
Luigi
--
Though this be madness, yet there is method in't.
-- Hamlet, Act II, scene II
|