[Boost-bugs] [Boost C++ Libraries] #3437: Unreachable code warning in Boost::property_tree macro

Subject: [Boost-bugs] [Boost C++ Libraries] #3437: Unreachable code warning in Boost::property_tree macro
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-09-11 17:25:10

#3437: Unreachable code warning in Boost::property_tree macro
 Reporter: Scott Bailey <Bailey@…> | Owner: kaalus
     Type: Bugs | Status: new
Milestone: Boost 1.41.0 | Component: property_tree
  Version: Boost 1.40.0 | Severity: Problem
 Keywords: ptree. unreachable code |
 The `BOOST_PROPERTY_TREE_THROW` macro us defined as follows:
     // 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_at_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_at_55966] to the
  * 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

Ticket URL: <https://svn.boost.org/trac/boost/ticket/3437>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:01 UTC