
Hi, I'm using boost::lexical_cast often in my application, but then I use it to convert strings to integral types and the compiler (MSVC 7.1) threw me a warning: C4701: local variable 'result' may be used without having been initialized Looking at lexical_cast implementation I found this template<typename Target, typename Source> Target lexical_cast(Source arg) { detail::lexical_stream<Target, Source> interpreter; // THIS is guilty of not been initialized Target result; if(!(interpreter << arg && interpreter >> result)) throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))); return result; } I was asking myself... why not use Fernando Cacciola's boost::value_initialized to avoid these warnings? template<typename Target, typename Source> Target lexical_cast(Source arg) { detail::lexical_stream<Target, Source> interpreter; // This can't raise any uninitialized related warning boost::value_initialized<Target> result; if(!(interpreter << arg && interpreter >> get(result))) // Must use get idiom throw_exception(bad_lexical_cast(typeid(Source), typeid(Target))); return get(result); // Must use get idiom } Somebody can explain me this? Is this warning a compiler issue? Thanks in advance Berny Cantos AZ Interactive SL