When an exception is thrown the program terminates instead of catching the
exception. This only happens with -O1 or higher and -fomit-frame-pointer.
The problem does not occur when:
- the throwing function is not virtual
- the throwing function is not an operator
- the throwing function does not call the non-inline base class function
Disabling parts of -O1 still triggers the problem ( -fno-defer-pop
-fno-merge-constants -fno-thread-jumps -fno-loop-optimize -fno-if-conversion
-fno-if-conversion2 -fno-guess-branch-probability -fno-cprop-registers )
Output of attached test-case with -O:
# throwing...
CATCHED UNKNOWN EXCEPTION.
Output of attached test-case with -O1 -fomit-frame-pointer:
# throwing...
terminate called after throwing an instance of 'std::range_error'
what(): Test exception.
Aborted
--
Summary: Incorrect termination after exception is thrown, if
compiled with -O1 -fomit-frame-pointer
Product: gcc
Version: 3.4.5
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bduerner at gmx dot de
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24288