public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54267] New: std::exception not catched when -O3 (-Os is fine, link static, FreeBSD 9.0-RELEASE-p3)
@ 2012-08-15  2:01 david.keller at litchis dot fr
  2012-08-15  2:10 ` [Bug c++/54267] " david.keller at litchis dot fr
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: david.keller at litchis dot fr @ 2012-08-15  2:01 UTC (permalink / raw)
  To: gcc-bugs

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: unassigned@gcc.gnu.org
        ReportedBy: david.keller@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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-08-15 15:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-15  2:01 [Bug c++/54267] New: std::exception not catched when -O3 (-Os is fine, link static, FreeBSD 9.0-RELEASE-p3) david.keller at litchis dot fr
2012-08-15  2:10 ` [Bug c++/54267] " david.keller at litchis dot fr
2012-08-15  2:58 ` david.keller at litchis dot fr
2012-08-15  3:01 ` [Bug target/54267] " pinskia at gcc dot gnu.org
2012-08-15  3:05 ` david.keller at litchis dot fr
2012-08-15  3:16 ` david.keller at litchis dot fr
2012-08-15  3:34 ` david.keller at litchis dot fr
2012-08-15  3:40 ` david.keller at litchis dot fr
2012-08-15 15:55 ` david.keller at litchis dot fr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).