Search code examples
c++11qt-creatorstdmapautostdset

Is that a bug in Qt Creator analizer


While working with some code I experienced QT Creator performance degradation. Actually it launches a thread that occupies 100% CPU in an infinite loop: even closing the IDE process without killing it becomes impossible. This is fully reproducible on my machine. Before submitting a bug I wish to get a confirmation from other users and to collect some statistics for the versions of QT Creator, OS, compiler, STL, etc. The code requires C++11 and higher.

After some investigation I reduced my code to the shortest sample that reproduces the issue (don't look at the symantics of the code, the problem is in how does the IDE treats it):

#include <set>
int main() {
    std::set<int> s;
    auto iter = s.insert(1).first;
    iter->second;
    return 0;
}

The highlights:

  • auto is important
  • the same behavior can be reproduced with the map instead of the set
  • insert is important as it returns not a simple iterator but a pair< iterator, bool>
  • The line iter->second is symantically incorrect, but that is not important (you may use std::set< std::pair> to make it correct). The problem is that the IDE crashes after iter-> whatever it could mean.

My configuration is: QT Creator 3.5.1 based on Qt 5.5.1 (MSVC 2013, 32 bit); Windows 10.


Solution

  • A lot has happened since Qt Creator 3.5. The code model is completely new, based on Clang. Hence, I cannot reproduce your problem with Qt Creator 4.9. (And yes, the old code model had several limitations and bugs.)

    In general, always make sure you have the latest supported version of the software before you prepare a bug report.