You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Eric Lemings <Er...@roguewave.com> on 2008/07/09 22:35:15 UTC

Initialize by throwing an exception?

 
tests/containers/23.vector.cons.cpp:
...
685 #ifndef _RWSTD_NO_EXCEPTIONS
686
687     try {
688         // throw an exception to initialize the lib (allocates
689         // memory that's never deallocated; shows up as leaks)
690         _RW::__rw_throw (_RWSTD_ERROR_LOGIC_ERROR, "", "");
691     }
692     catch (...) {
693     }
694
695 #endif   // _RWSTD_NO_EXCEPTIONS
...

This seems very odd.  Initializing the library by throwing an exception.
Or is this meant only to initialize the exception handling portions of
the library?

Was hoping someone could shed some light on this.

Brad.

Re: Initialize by throwing an exception?

Posted by Martin Sebor <se...@roguewave.com>.
Eric Lemings wrote:
>  
> tests/containers/23.vector.cons.cpp:
> ...
> 685 #ifndef _RWSTD_NO_EXCEPTIONS
> 686
> 687     try {
> 688         // throw an exception to initialize the lib (allocates
> 689         // memory that's never deallocated; shows up as leaks)
> 690         _RW::__rw_throw (_RWSTD_ERROR_LOGIC_ERROR, "", "");
> 691     }
> 692     catch (...) {
> 693     }
> 694
> 695 #endif   // _RWSTD_NO_EXCEPTIONS
> ...
> 
> This seems very odd.  Initializing the library by throwing an exception.
> Or is this meant only to initialize the exception handling portions of
> the library?

The latter. I suspect this might be a white box test for the
old (pre-3.0) version of the library. The new library shouldn't
leak anything. Feel free to remove this bit after verifying my
hypothesis :)

Martin