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



             Bug #: 56742

           Summary: Optimization bug lead to uncaught throw

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: kti...@gcc.gnu.org

            Target: x86_64-w64-mingw32, x86_64-pc-cygwin





Hi,



the following testcase:



#include <string>



static int main_worker(int argc)

{

  std::string s[32]; // [31] => no segfault

  if (argc < 2)

    throw 42;

  return argc;

}



int main(int argc, char **argv)

{

  try {

    return main_worker(argc);

  }

  catch (int i) {

    return i;

  }

}



produces with optimization -O2 on execution the message:

 "terminate called after throwing an instance of 'int'"

and abort gets called.



If compiled with optimization level -O1, execution works as expected.

Reply via email to