Posted by
Luigi Ballabio on
URL: http://quantlib.414.s1.nabble.com/potentially-uninitialized-local-variables-in-Analytic-GJR-GARCH-1-1-Engine-tp12134p12135.html
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
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.
http://p.sf.net/sfu/bobj-july_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev