PDA

View Full Version : Using exceptions in Qt 5.1.1 crashes the program



themagician
24th November 2013, 18:34
OS: Windows 7
Compiler: GCC 4.8.1
Qt: 5.1.1
Qt Creator 2.8.1

I create a project through File -> New File or Project... -> Applications -> Qt Gui Application.

I open the default mainwindow.cpp file.

I add the following lines to the first lines:


#include <exception>
#include <stdexcept>
#include <QDebug>

Then in the MainWindow constructor below ui->setupUi(this); I add the following lines:


try {
throw std::runtime_error("asd");
}
catch(std::exception& ex) {
qDebug() << ex.what();
}

I compile and run the program -> program crashes. I've tried throwing integers and catching by ... and always the same result.

The Compile Output window shows -fexceptions is used as argument for GCC.

The Application Output window shows Invalid parameter passed to C runtime function. as error.

It works fine in non-Qt C++ applications. It also works fine with Qt 5.0.2. What's going on here?