http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54267

             Bug #: 54267
           Summary: std::exception not catched when -O3 (-Os is fine, link
                    static, FreeBSD 9.0-RELEASE-p3)
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: david.kel...@litchis.fr


1 #include <iostream>
  2 #include <boost/asio.hpp>
  3
  4 /**
  5  *  This exception is uncatchable !
  6  */
  7 void
  8 do_throw_uncatchable
  9     ( void )
 10 {
 11     // Simulate a boost::asio::error
 12     boost::asio::detail::throw_error( boost::asio::error::eof, "asio" );
 13 }
 14
 15 /**
 16  *  Now the exceptions thrown becomes catchable,
 17  *  when the function lives in an anonymous namespace.
 18  */
 19 namespace {
 20
 21 void
 22 do_throw_catchable
 23     ( void )
 24 {
 25     // Simulate a boost::asio::error
 26     boost::asio::detail::throw_error( boost::asio::error::eof, "asio" );
 27 }
 28
 29 } // anonymous namespace
 30
 31
 32 /**
 33  *  Expect:
 34  *  #############
 35  *  catched catchable
 36  *  catched uncatchable
 37  *  ############
 38  *
 39  *  But see:
 40  *  #############
 41  *  cacthed catchable
 42  *  terminate called after throwing an instance of
'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error>
>'
 43  *    what():  asio: End of file
 44  *    Abort trap (core dumped)
 45  *  #############
 46  */
 47 int
 48 main
 49     ( int argc
 50     , char* argv[] )
 51 {
 52     try
 53     {
 54         do_throw_catchable();
 55     }
 56     catch ( std::exception const& )
 57     {
 58         std::cout << "catched catchable" << std::endl;
 59     }
 60
 61     try
 62     {
 63         do_throw_uncatchable();
 64     }
 65     catch ( std::exception const& )
 66     {
 67         std::cout << "catched uncatchable" << std::endl;
 68     }
 69
 70     return 0;
 71 }
 72


g++48  -ftemplate-depth-128 --std=c++11 -Os -finline-functions -Wno-inline
-Wall -pthread  -DBOOST_ALL_NO_LIB -DBOOST_ASIO_HAS_MOVE -DNDEBUG -c -o
"bin/gcc-4.8/release/link-static/optimization-space/threading-multi/main.o"
"main.cpp"

g++48    -o
"bin/gcc-4.8/release/link-static/optimization-space/threading-multi/main"
-Wl,--start-group
"bin/gcc-4.8/release/link-static/optimization-space/threading-multi/main.o" 
-Wl,-Bstatic -lboost_system -Wl,-Bdynamic  -Wl,--end-group
-Wl,-rpath,/usr/local/lib/gcc48 -Wl,--strip-all -pthread



I'll try to reproduce without boost.

Reply via email to