I am using Raisonance's Ride7/Codesourcery (a.k.a Sourcery CodeBench Lite) with an STM32F4 board developing a bare metal HMI platform.
I will be making use of C++ exceptions in this system, but any exception I throw ends with a "Terminate called recursively" error written to stderr.
Code to reproduce the problem: (main.cpp)
int main(void)
{
try {
throw 1;
}
catch (...) {
printf("caught");
}
}
I've already tried Raisonance and other sources for a resolution, and have not received any actionable help.
Potential problem/solution 1:
I've asked on other forums and they mention I need to call static constructions in my startup assembly file to initialize the unwind tables (at least that's what I think they are talking about), but I have no idea how to do this.
Potential problem/solution 2
I have also discovered a bug in binutils/gas that may be the source of my problems here (http://sourceware.org/bugzilla/show_bug.cgi?id=13449). I've been trying to build my own version of the toolchain with this patch, but that's turning into a project of its own, and have not yet succeeded.
The Question
Do I need to do something in code to make use of C++ exceptions, or is this likely a bug in the toolchain? If the former, please elaborate.
gcc
,g++
, or a custom linker line? (Linking withg++
does a lot of magic to make strange C++ features work, so if you're not using that, try it and see what happens.) – Lailg++
just passes-lstdc++ -lm
to the linker, not much magic. – Albania-fexceptions
explicitly. It's supposed to be enabled by default for C++, but if your build system usesgcc
for some things, instead ofg++
, there might be trouble. – Seltzer-fexceptions
and usingg++
instead ofgcc
. Still not luck. – Clownery