[SOLVED] Q_ASSERT doesn’t crash an application in debug run
-
Qt 4.7.4
Qt Creator 2.2.1I have a problem probably with Qt Creator. Today I found that Q_ASSERT doesn't work correctly on my Linux. In the past everything worked good. I tested Q_ASSERT like this:
@
Q_ASSERT( false );
@
This code crashes my app in Qt Creator only if I run by Run(Ctrl+R), but when I hit a Debug Run(F5) then Qt Creator jumps to Q_ASSERT line like to a breakpoint and doesn't crash my application.On Windows I have similar Qt and Qt Creator, but there Q_ASSERT crash application in Run and Debug Run. I think that something is wrong with Qt Creator settings, but I don't know what.
On Windows and Linux I compiled program in debug mode.
Sorry for my english.
-
basically the thing is that when u compile ur code in the debug mode then compiler will compile ur entire code including the asserts, but when u compile ur code in release mode the compiler will skip the assert and many other thing, basically cimpiler is not skipping them its supressing these warnings in the runtime, so when u compile ur code in release mode the ur code will not crash.
but i prefer u to to do ur entire development in the debug mode, so thet u can handle aal the runtime errors which u may get in future, and after all coding of ur roject is done then u can release ur project using the release mode...
so always develop in debug mode and deploy in release mode...:)
-
-
When you're running an app in a debugger and the application ends abnormally (a crash, or an abort, or a failed assertion, or whatever) the debugger "catches" the application at the point where the program terminated. That's the way a debugger is supposed to work. Or am I missing something else that you're expecting to happen?
-
-
Example:
@
#include <QtCore/QCoreApplication>#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);Q_ASSERT( false ); qDebug() << "I'm alive!"; return a.exec();
}
@
Debug build. Then start debugging(F5) - output:
@
I'm alive!
@Start in Qt Creator by run(Ctrl+R) - output:
@
ASSERT: "false" in file ../assert_issue/main.cpp, line 9
The program has unexpectedly finished.
@Start outside Qt Creator - output:
@
ASSERT: "false" in file ../assert_issue/main.cpp, line 9
Przerwane (core dumped)
@