Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. How to know Which line when “index out of range"?
Forum Updated to NodeBB v4.3 + New Features

How to know Which line when “index out of range"?

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
7 Posts 2 Posters 960 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JXF2008
    wrote on 12 Jul 2021, 05:47 last edited by
    #1

    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.

    J 1 Reply Last reply 12 Jul 2021, 05:49
    0
    • J JXF2008
      12 Jul 2021, 05:47

      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.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 12 Jul 2021, 05:49 last edited by
      #2

      @JXF2008 How about using debugger? It will show you exactly where this happens...
      And from the error message it is actually clear where it happens (hint: names.remove(i)).

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      J 1 Reply Last reply 12 Jul 2021, 06:08
      0
      • J jsulm
        12 Jul 2021, 05:49

        @JXF2008 How about using debugger? It will show you exactly where this happens...
        And from the error message it is actually clear where it happens (hint: names.remove(i)).

        J Offline
        J Offline
        JXF2008
        wrote on 12 Jul 2021, 06:08 last edited by
        #3

        @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"

        J 1 Reply Last reply 12 Jul 2021, 06:14
        0
        • J JXF2008
          12 Jul 2021, 06:08

          @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"

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 12 Jul 2021, 06:14 last edited by
          #4

          @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.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          J 1 Reply Last reply 12 Jul 2021, 06:19
          0
          • J jsulm
            12 Jul 2021, 06:14

            @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.

            J Offline
            J Offline
            JXF2008
            wrote on 12 Jul 2021, 06:19 last edited by
            #5

            @jsulm
            For instance,coule tell me the name of file and which lines?
            qline.png

            J 1 Reply Last reply 12 Jul 2021, 06:25
            0
            • J JXF2008
              12 Jul 2021, 06:19

              @jsulm
              For instance,coule tell me the name of file and which lines?
              qline.png

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 12 Jul 2021, 06:25 last edited by jsulm 7 Dec 2021, 06:26
              #6

              @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

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              J 1 Reply Last reply 12 Jul 2021, 06:29
              2
              • J jsulm
                12 Jul 2021, 06:25

                @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

                J Offline
                J Offline
                JXF2008
                wrote on 12 Jul 2021, 06:29 last edited by
                #7

                @jsulm
                Tks....

                1 Reply Last reply
                0

                1/7

                12 Jul 2021, 05:47

                • Login

                • Login or register to search.
                1 out of 7
                • First post
                  1/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved