id summary reporter owner description type status milestone component version severity resolution keywords cc 3437 Unreachable code warning in Boost::property_tree macro Scott Bailey Sebastian Redl "The `BOOST_PROPERTY_TREE_THROW` macro us defined as follows: {{{ #!cpp // Throwing macro to avoid no return warnings portably # define BOOST_PROPERTY_TREE_THROW(e) { throw_exception(e); std::exit(1); } }}} When using '''MSVS v8.0''' with warning level 4, this line generates warning 4702, unreachable code. === Why This Matters === Although much of warning level 4 is arguably MORE than necessary, unreachable code warnings can help find code one thought should execute, as well as trim code the indeed is unreachable. This warning should NOT, in my opinion, be disabled project wide, unlike certain other level 4 warnings. Further, I prefer to set warnings as errors to ensure I follow my own advice. === Where === The source of this defect is the BOOST_PROPERTY_TREE_THROW macro, found in `property_tree/ptree_fwd.hpp`, v55966, on line 139. Link: [source:trunk/boost/property_tree/ptree_fwd.hpp@55966#L139] === Possible Resolutions === For whatever reason -- although I assume it is related to templates -- `# pragma warning(disable: 4702)` won't disable this warning, which essentially means the offending unreachable code must be removed; however, I think it's there to provide an exit when exceptions are disabled. Would it be better to provide a different macros based on exception state? I believe this is how MS implements this for the STL... Perhaps [source:trunk/boost/throw_exception.hpp boost/throw_exception.hpp] should be evaluated? If only for the `BOOST_NO_EXCEPTIONS` macro. === Recreating === Recreation can be done as follows: * Open MSVS * Create a new console app * add ""existing"" file [source:trunk/lib/property_tree/examples/debug_settings.cpp@55966] to the project * add include of stdafx.h to debug_settings.cpp * set properties: * warning level 4 * warnings as errors * add boost location to the include search path * build the project" Bugs closed Boost 1.41.0 property_tree Boost 1.40.0 Problem fixed ptree. unreachable code Scott Bailey mateusz@…