Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-17253

Segfault when right-clicking on erroneous code in function definition

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P1: Critical P1: Critical
    • Qt Creator 4.2.0-rc1
    • Qt Creator 4.1.0
    • C/C++/Obj-C++ Support
    • None
    • Linux x86_64 (Arch Linux)

      I have encountered a crash with the following code:

      container.h
      #include <vector>
      
      std::vector<int> vec;
      
      void myfunc()
      some_text
      {
        for (int element : vec) {
      
        }
      }
      

      The function definition is incorrect and causes the line for (int element : vec) { to be underlined in yellow, which is expected. However, if I right-click this line, QtCreator crashes.

      Steps to reproduce :

      • Create a new project: "Plain C++ Application", with qmake build system (I've had the issue with CMake as well so I don't think it matters)
      • Create a new class with any name
      • Remove the class declaration code in the class header file, and replace it with the code above
      • Right-click on the for line.

      The function isn't declared nor defined anywhere else.
      The crash doesn't happen if I remove the for's braces.
      The crash only happens in header files that have been created using "New C++ Class".

      I have included a stack trace.
      Feel free to ask for details if needed.

        1. trace.log
          3 kB
          Hector Labanca
        2. crashtest.pro
          0.1 kB
          Hector Labanca
        For Gerrit Dashboard: QTCREATORBUG-17253
        # Subject Branch Project Status CR V

            kosjar Nikolai Kosjar
            ranjak Hector Labanca
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes