Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Static Analysis for Qt Objects and containers?
Forum Updated to NodeBB v4.3 + New Features

Static Analysis for Qt Objects and containers?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 303 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.
  • I Offline
    I Offline
    i-dream-in-code
    wrote on last edited by
    #1

    I have a very simple example that refuses to be flagged by either clang, clang-tidy, clazy, or Krazy2.

    QVector<int> myVec;
    myVec.push_back(1);
    myVec.push_back(2);
    int third = myVec.at(3);
    int otherThird =myVec[3];
    

    obviously this segfaults because there was never a third element.

    The issue is that no single IDE or plugin will flag this. It'll ASSERT in Qt Creator debug build run but that's after it compiles.

    there has to be some intellisense like thing in the editor or any static analysis tool that can read Qt Containers.

    "Just add the Qt source to your code model" you might say well compiling every single part of Qt takes many days so not an option.

    Another example is

    QCheckBox *myCheckbox = new QCheckBox();
    QListView *myListView = qobject_cast<QListView *>(myCheckBox); //will  equal null
    QSize size = myListView->gridSize(); //myListView is null so crashes with segfault again
    

    This leads to deep bugs that aren't flagged with any static analysis tool.

    Any advice please on how to find these bugs?

    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