Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Debugging "index out of range " - suggestions please - can Qt IDE provide more help ?



  • OK, I know what the error is , what I am asking is
    how do you identify the actual code where the error "comes from"?
    All I have is the line in header reporting the error. How do I backtrack the actual source of the run time error ? Or is is even possible.
    So far I have been stepping thru the code in debug mode , but it is little tedious.

    I have several similar test codes and it would be helpful if I could identify the actual line where the "index" out of range is detected.

    I know this is C code logical error, I am asking if there is a way to let Qt IDE help identifying the source , not just header line reporting the error.

    // test retrieve QStringList local data
     current data size    4
     QStringList  test data  ("address ", "B8:27:EB:11:3F:82")  @ index   1
     QStringList  test data  ("name    ", "ARM")  @ index   2
     QStringList  test data  ("address ", "B8:27:EB:11:3F:82", "    name    ", "ARM")  @ index   3
    ASSERT failure in QVector<T>::at: "index out of range", file /usr/include/x86_64-linux-gnu/qt5/QtCore/qvector.h, line 393
    The program has unexpectedly finished.
    /media/d/QT/QT_PROJECT_CAT/build-TEST_PROJECT-Desktop-Debug/TEST_PROJECT crashed
    

  • Lifetime Qt Champion

    @AnneRanch said in Debugging "index out of range " - suggestions please - can Qt IDE provide more help ?:

    how do you identify the actual code where the error "comes from"?

    Use a debugger, take a look in the backtrace from where it comes from.


  • Lifetime Qt Champion

    Hi
    As Mr Ehrlicher says, it should be visible in the debugger window

    I added some code that crash in maindows and then it looks like this

    alt text


Log in to reply