[gccsdk] C++ exceptions not working with GCCSDK 4.7

Alan Buckley alan_baa at hotmail.com
Fri Aug 15 06:59:29 PDT 2014


I seem to be having a problem with programs not catching C++ exceptions
when compiled with GCCSDK 4.7.
Full version: 
(GCCSDK GCC 4.7.4 Release 1 Development) 4.7.4 20140527 (
prerelease) [gcc-4_7-branch revision 210956]

The following simple program (main.cc) will crash rather than catch
the exception as expected.

#include <iostream>
#include <stdexcept>

int main(int argc, char *argv[])
{
    try
    {
        std::cout << "Before throw" << std::endl;
        throw std::runtime_error("Test throw and catch");
    } catch(...)
    {
        std::cout << "Caught thrown exception as expected\n" << std::endl;
    }
    std::cout << "After try/catch block" << std::endl;
}

I’m compiling it using the following makefile.

# Makefile for exceptcrash

SRC=main.cc
CXX=~/gccsdk/cross/bin/arm-unknown-riscos-g++
CXXFLAGS= -O2 -mthrowback
TARGET=exceptnotcaught


all:    $(TARGET)

$(TARGET):    $(SRC:.cc=.o)
    $(CXX)  -static $(SRC:.cc=.o) -o $(TARGET)ELF,e1f
    ~/gccsdk/cross/bin/elf2aif $(TARGET)ELF,e1f $(TARGET),ff8


The ELF version crashes as well at the aif version.

The output from the program is:

Before throw
terminate called after throwing an instance of 'std::runtime_error'
terminate called recursively

Fatal signal received: Aborted

Stack backtrace:

Running thread 0x84968
  (  c56e84) pc:    6c774 lr:    6cc18 sp:   c56e88  __write_backtrace()
  (  c56ef4) pc:    6c890 lr:    6cf7c sp:   c56ef8  __unixlib_raise_signal()
  (  c56f04) pc:    6cf60 lr:    536cc sp:   c56f08  raise()
  (  c56f18) pc:    53690 lr:    3d1e4 sp:   c56f1c  abort()
  (  c56f38) pc:    3d118 lr:    34b08 sp:   c56f3c  __gnu_cxx::__verbose_terminate_handler()()
  (  c56f48) pc:    34afc lr:    34b60 sp:   c56f4c  __cxxabiv1::__terminate(void (*)())()
  (  c56f8c) pc:    3d114 lr:    34b08 sp:   c56f90  __gnu_cxx::__verbose_terminate_handler()()
  (  c56f9c) pc:    34af8 lr:    34b60 sp:   c56fa0  __cxxabiv1::__terminate(void (*)())()
  (  c56fec) pc:     84f0 lr:    5828c sp:   c56ff0  main()


Can anyone else confirm this isn’t working?

Regards,
Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riscos.info/pipermail/gcc/attachments/20140815/436f3444/attachment.html>


More information about the gcc mailing list