Tuesday, 15 March 2011

c++ - BOOST_THROW_EXCEPTION causes infinite recursion -


I'm using 1.53.0 promotions, and there has not been any problem (and sockets, Timer,

I like the idea of ​​using exception exceptions, especially due to line number.

However, in my (super simple), code: #include & lt; iostream & gt; # Include & lt; fstream & gt; # Include & lt; boost / scoped_ptr.hpp & gt; #include & lt; boost / exception / all .hpp> Struct my_error: virtual boost: exception, virtual std :: exception {}; int main ( Int argc, char * argv []) {try {BOOST_THROW_EXCEPTION (my_error ());} hold (...) {std :: cout << "failed";}} cmake_minimum_required (version 2.8) project (error_test) If set (Win32) set ((Boost_USE_STATIC_LIBS ON) set with the project CMake (hopefully it is not over screwing) (Boost_USE_MULTITHREADED on) set (Boost_USE_STATIC_RUNTIME off) set (Boost_NO_SYSTEM_PATHS FALSE) ENDIF () find_package (date_time_package component component system) include_directories ($ {Boost_INCLUDE_DIRS}) add_executable ($ {PROJECT_NAME} main.cpp) target_link_libraries ($ {PROJECT_NAME} $ {Boost_LIBRARIES})

Throw instead, BOOST_THROW_EXCEPTION is an infinite Enters into Rtyawartn!

The compiler also explains this catch, a compiler warning

Warning C4717: 'Promote: exception_detail :: throw_exception_':. On all the control paths, the recurring function will be the cause of the overload flow

and it just keeps hitting:

  Test.exe! Boost :: exception_detail :: throw_exception_ & lt; My_error & gt; (Const my_error & x, const char * current_function, const char * file, integer line) Lee has 84 + 0xd1 bytes C ++   

I'm winning Visual Studio 2010 ). I encourage the following command, if it helps:

  .b2 install --prefix = C: \ devtools \ boost_1_53_0 --toolset = msvc --build-type = Complete - Construction-directory = C: \ DevTools \ bin \ boost_1_53_0 Address Model = 64 Architecture = 86   

Edit extension macro is being added:

Macro's It seems to be expanded

  :: boost :: exception_detail :: throw_exception_ (my_error (), __FUNCSIG__, "main.cpp", 40);   

that

  throw_exception_ (e const & amp; x, char const * current_function, char const * file, interval line) {:: boost: Exception_detail :: throw_exception_ (set_info (set_info (enable_error_info (x), throw_function (current_function), throw_file (file)), throw_line (line)), __FUNCSIG__, "C: \\ DevTools \\ boost_1_53_0 \\ boost / throw_exception .hpp ", 91);   

#line 92 "C: \ DevTools \ boost_1_53_0 \ boost / throw_exception.hpp"}

It's just plain weird. As you can easily check on boost :: exception :: throw_exception_, there is no recurring at all.

In the same way, I can see that this is with evil macros. Please try putting it in your main file, before and after the instructions in each.

  #if define (throw_exception) || Defined (throw_exception_) #Terror Someone can call us #endif    

No comments:

Post a Comment