How to know Which line when “index out of range"?
-
There is a spimle error,
QVector<QString> names({"Jack","Mike"}); for(int i = 0 ; i < 4 ; ++i) qDebug()<<names.remove(i);
When i click "RUN" that a button in QtCreator,and the APP is running ,and the APP is crash.....
Now QtCreator will tell me like this
ASSERT failure in QVector<T>::remove: "index out of range", file D:\Qt\Qt5.13.1\5.13.1\msvc2017_64\include\QtCore/qvector.h, line 468
But there is problem,how to know whick line that happend the "index out of the range",i want to know which file and which line because the object has 100 files and over 190 thousand lines.
-
@jsulm
Yes,QtCreator tell me there is a "index out of range",but QtCreator donw't tell me which file and whick lines.It only tell me "ASSERT failure in QVector<T>::remove: "index out of range", file D:\Qt\Qt5.13.1\5.13.1\msvc2017_64\include\QtCore/qvector.h, line 468"
-
@JXF2008 said in How to know Which line when “index out of range"?:
Yes,QtCreator tell me there is a "index out of range",but QtCreator donw't tell me which file and whick lines
It does, check the stack trace.
In this case the ASSERT is triggered in qvector.h file, but if you go back in the stack trace you will see the line in your code which caused the ASSERT. -
@JXF2008 Did you read what I wrote?
Run your app through debugger (press F5), and as soon as it terminates check the stack trace (in Debugger view).
See also https://forum.qt.io/topic/107914/how-to-view-backtrace-stacktrace/4