0
votes

I ran my project in release mode and I had no problem. and than I changed the mode to debug mode and I have an error "debug assertion failed".

That's the code that caused it:

   QXmlStreamReader* xmlReader = new QXmlStreamReader(xmlFile);
   xmlReader->readNextStartElement();

   QXmlStreamAttributes attributes;
   attributes = xmlReader->attributes();
   cout << (attributes.value("name").toString().toStdString());

After this cout line I had the error massage.

What can be the difference between the modes that caused the difference?

I want to know what I need to change for running the project in debug mode.

1
What does the debug assertion actually say. Typically, assertions tell you something - for example, you may not have a "name"? - Mats Petersson
but in release mode there is no error. - STF
In release mode the debug assertion is probably not being tested - Colin

1 Answers

1
votes

The difference between the modes is that in release mode

assert( expr );

compiles to nothing. In debug mode it compiles to something like:

if (!(expr))
   assert_failed( "expr" );

(The above is to give the flavour, there are some subtleties). What this means is that you didn't notice the problems in release mode (you probably did something like write over some unused memory). Murphy's Law says that you will notice the problems when you come to demo to a big customer / your professor.

If you look at the line where the assertion occurs, it will tell you what it is complaining about. You need to fix that.