|
Boost : |
From: Kris Braun (kris_braun_at_[hidden])
Date: 2004-01-05 12:19:27
Reece Dunn wrote:
> [2] C4701: local variable 'result' may be used
without having been
> initialized
> at lexical_cast.hpp(191)
>
> This is the warning I think you are referring to. I
don't understand your
> fix -- adding __declspec(noreturn) to the
throw_exception function does
> nothing. The warning is referring to the line:
> Target result;
> where the variable result has not been given a
value.
> Target result = Target();
> will remove the warning (since Target result();
results in a function
> decleration, not variable initialization!)
Yes, that is the warning. It can be solved by
initializing result, but that isn't necessary for
correctness, since result will always be initialized
when used (returned). It could only be returned
uninitialized if throw_exception returns, which should
not happen. Believing there may be other situations
like this, and wanting to save an unnecessary
constructor call, I thought informing the compiler
that throw_exception won't return was a better option.
I've verified that add #declspec( noreturn ) fixes the
warning for me.
Cheers,
Kris
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk