February 25, 2016 - 11:49am
Guido Saßmannshausen |
Hi, when compiling int main() { try { throw our_namespace::timeout_error(); // happens with throw std::runtime_error() or throw(int()) as well } catch(const std::runtime_error & e) { // .. } catch(const std::exception & e) { // .. } catch(...) { // .. }
none of the catch blocks are entered, and stepping through the assembly, I notice that we pass get_unexpected() which should usually only occur, when a deprecated execption specification is violated. As there is no chance for a block local try/catch sequence to have an exception specification, this is quite irritating.
Does anyone have any idea, where to look for a fix, or is this somehow affected by the default startup files/linker scripts? (It is of course, but does anyone have experience, of them failing to support exceptions?) In the past (with the previous version of RKit-ARM) I happened to see working exceptions, but since -fexceptions became the default, it ceased to work.
Help welcome, and if I forgot to mention any relevant information, slap me ;)
Build configuration: RKit-ARM 1.62.15.0334 compiling and linking with exception handling enabled, no optimisations, debug info enabled and explicitly stating "-fexceptions" (just to be sure) redundantly as command line opton.
|
Explanation of the problem...:
* newlib-nano is an alternative version of the GCC libraries optimized by ARM for embedded systems.
* for performance and code size considerations, it is compiled without exception support. (this is a choice made by ARM, which could be discussed... but not with us ;( )
* RKit-ARM 1.60, which is "the previous version that seemed to work", did use newlib-nano. But there was a bug in this integration, and as a result of this bug the C++ libraries were never in the "nano" version, even if you activated the "newlib-nano" option. So the exceptions were working but you did not fully benefit from the "nano" improvements.
Moreover, you were in an inconsistent state (linking newlib-nano for C and newlib "not nano" for C++), potentially vulnerable to problems much more critical that code size issues.
* In RKit-ARM 1.62, which is the current version on which you don't manage to use exceptions, when you activate the newlib-nano option you do it for the whole system, including C++, not just C. As a result you are now in a much more consistent (and therefore more reliable) state, but you don't have exception support.
What you can do, depending on your situation...:
* Stop using exceptions. (which will force you to modify your code)
* OR stop using newlib-nano. (which will make your code grow a lot)
We do NOT recommend reverting to the previous inconsistent state, neither by reinstalling the previous RKit-ARM nor by tweaking the scripts or libraries, because if you this we would expect some critical and unpredictable problems, and we would not help you about these.