Boost C++ Libraries: Ticket #3286: assert()-like functionality in release mode https://svn.boost.org/trac10/ticket/3286 <p> I think an assert() that also works in release mode would be good to have. There is too much code where errors aren't being handled properly. I think such a new assert() would lower the barrier to do error checking. </p> <p> MFC has VERIFY(), although ignores failures in release mode. I don't think that's the best approach. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3286 Trac 1.4.3 Steven Watanabe Fri, 24 Jul 2009 01:03:32 GMT <link>https://svn.boost.org/trac10/ticket/3286#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3286#comment:1</guid> <description> <p> The expansion of assert is controlled by the macro NDEBUG independently of optimization options. Because of the way assert is designed, it is always a bug if an assertion fails. This is due to more than just the fact that assertions can be disabled. It is also due to the fact that a failed assertion crashes the program. In addition, proper handling of errors that are not bugs is much more complex than assert is capable of handling. </p> </description> <category>Ticket</category> </item> <item> <author>Olaf van der Spek <OlafvdSpek@…></author> <pubDate>Fri, 24 Jul 2009 09:58:45 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3286#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3286#comment:2</guid> <description> <p> Are you suggesting I just don't define NDEBUG? That's not an optimal solution, as leaving assert() enabled could give a performance hit, because it's usually expected to be gone in release mode. The app is supposed not to depend on assert expressions being evaluated, that's why there should be another construct that is not excluded (by default) in release mode. </p> <p> I agree that it's certainly not suitable for all error handling. That doesn't mean there aren't a lot of situations where it would come in handy. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 07 Jun 2010 09:42:07 GMT</pubDate> <title>component changed; owner set https://svn.boost.org/trac10/ticket/3286#comment:3 https://svn.boost.org/trac10/ticket/3286#comment:3 <ul> <li><strong>owner</strong> set to <span class="trac-author">No-Maintainer</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">utility</span> </li> </ul> Ticket olafvdspek@… Tue, 12 Apr 2011 22:59:41 GMT <link>https://svn.boost.org/trac10/ticket/3286#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3286#comment:4</guid> <description> <p> Somebody? I'm willing to work on this one myself if the feature would be accepted into Boost. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 03 Jun 2012 20:27:48 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3286#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3286#comment:5</guid> <description> <p> Send a post to the dev ML requiring interest in the feature. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Sat, 08 Jul 2017 20:48:28 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/3286#comment:6 https://svn.boost.org/trac10/ticket/3286#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> There is the <code>BOOST_VERIFY(x)</code> macro, which is expands to <code>x</code> in release builds and <code>BOOST_ASSERT(x)</code> in debug. There is also <code>BOOST_VERIFY_MSG</code>. Note that these macros do not implement error handling in release builds. </p> <p> If you want to do an actual error handling in release (e.g. abort in case of error) then asserts are not the right tool for this, IMO. Use exceptions or explicitly spell out the error handling behavior. </p> Ticket