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

    jsulmJ 1 Reply Last reply
    0
    • J JXF2008

      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.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on 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
      0
      • jsulmJ jsulm

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

        jsulmJ 1 Reply Last reply
        0
        • J JXF2008

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

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on 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
          0
          • jsulmJ jsulm

            @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 last edited by
            #5

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

            jsulmJ 1 Reply Last reply
            0
            • J JXF2008

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

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by jsulm
              #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
              2
              • jsulmJ jsulm

                @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 last edited by
                #7

                @jsulm
                Tks....

                1 Reply Last reply
                0

                • Login

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