In one of my C++14 programs I encountered exception behaviour that I do not understand / did not expect. Can somebody please enlighten me?
I have an abstract baseclass which looks like that (simplified): There is a method "templateLoop" which encapsulates over try/catch all block the abstract method doReadStat which is implmeneted in dervied classed. There is also a start method which executed the templateLoop in a thread.
class BaseStatReader{
virtual void doReadStat()=0;
void templateLoop() {
try {
doReadStat();
}
catch (...){
//cout ...
}
}
void start(){
t = std::thread([&](){ templateLoop();});
}
std::thread t;
};
Now I have a concrete derived class (lets call it ConcreteStatReader) which implments doReadStat. In the application code I instantiate an object of ConcrteStatReader and call start on it. Now within this concrete implementation of doReadStat() a floating point runtime exception occurs. To my understanding it should be caught in the baseclass templateLoop catch(...) block which it does not. The program terminates, the exception is never caught. why?