[libcxx] r177892 - Debug mode: learning to crawl. I need to set up some tests that actually test that the debug mode is working, but that won't cause problems when debug mode isn't on. This is my first prototype of such a test. It should call std::terminate() because it's comparing iterators from different containers. And std::terminate() is rigged up to exit normally. If debug mode fails, and doesn't call terminate, then the program asserts. The test is a no-op if _LIBCPP_DEBUG2 is not defined or is def...

Howard Hinnant hhinnant at apple.com
Mon Mar 25 17:45:38 PDT 2013


On Mar 25, 2013, at 8:42 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:

> On Mon, Mar 25, 2013 at 9:29 PM, Howard Hinnant <hhinnant at apple.com> wrote:
>> Author: hhinnant
>> Date: Mon Mar 25 14:29:35 2013
>> New Revision: 177892
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=177892&view=rev
>> Log:
>> Debug mode: learning to crawl.  I need to set up some tests that actually test that the debug mode is working, but that won't cause problems when debug mode isn't on.  This is my first prototype of such a test.  It should call std::terminate() because it's comparing iterators from different containers.  And std::terminate() is rigged up to exit normally.  If debug mode fails, and doesn't call terminate, then the program asserts.  The test is a no-op if _LIBCPP_DEBUG2 is not defined or is defined to be 0.
> 
> Hi Howard,
> 
> Maybe I'm missing something, but why go through std::terminate when
> you can put std::exit(0) here:
> 
>> +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::terminate())

<slaps forehead>  Makes perfect sense.  I had been playing around with throwing an exception and that wasn't working the way I wanted.  So I looked up how I tested terminate() and copy/pasted from there.  I was just over thinking it.

Thanks,
Howard




More information about the cfe-commits mailing list