[Qt-interest] Q_ASSERT_X fails when not false...

Eric Clark eclark at ara.com
Tue Nov 30 20:47:46 CET 2010


Hello All,

This is kind of a strange problem that I am running into and very difficult for me to give an example, so I was hoping that someone has run into the problem as well. I am trying to set the current index in a QTreeView and I am getting a failed assertion in QVector::at(int i). I followed the failed assertion with the debugger and checked the value of i against the assertion check. This is the code that I am referring to:

template <typename T>
inline const T &QVector<T>::at(int i) const
{ Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::at", "index out of range");
  return p->array[i]; }

The code is in qvector.h and it seems to make sense, however, the debugger says the value of i is 2 and the value of d->size is 15. With these values the assertion should pass the check, but it doesn't. I get a failed assertion. If I ignore the failed assertion everything works fine and the application continues to run. Which shows me that the value of i is a valid value. I am very confused with this and not real sure why the assertion is failing. I am using Qt 4.7.1 in both VC9 and VC10 and both of them are crashing in the same spot. The VC9 build is the commercial build from Qt and the VC10 build was built by me.

I don't know what I can do to get some help from someone with this problem other than to ask if anyone else has experienced something similar? I would really appreciate any help or advice that anyone could give me here. By the way, everything works fine in release mode because the assertion is never checked, but this also shows that the index is valid.

Thank You in Advance!
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101130/68ef93ed/attachment.html 


More information about the Qt-interest-old mailing list