Skip to content

Fixed Qt config macro declaration - #8796

Merged
chrchr-github merged 3 commits into
cppcheck-opensource:mainfrom
Daschle-Newberry:main
Aug 26, 2026
Merged

Fixed Qt config macro declaration#8796
chrchr-github merged 3 commits into
cppcheck-opensource:mainfrom
Daschle-Newberry:main

Conversation

@Daschle-Newberry

Copy link
Copy Markdown
Contributor

The macro definition of Q_ASSERT_X results in false positives.

Example

#include <QDebug>

void test()
{
    const char *where = "test";
    const char *what = "assertion failed";

    Q_ASSERT_X(false, where, what);
}

This code block results in:

style: Variable 'where' is assigned a value that is never used. [unreadVariable]
style: Variable 'what' is assigned a value that is never used. [unreadVariable]

The existing definition discards where and what arguments when modeling Q_ASSERT_X. The fix preserves these arguments using (void) (what) and (void) (where)

@chrchr-github

Copy link
Copy Markdown
Collaborator

Thanks for your contribution. Please add a test in test/cfg/qt.cpp.

@chrchr-github

Copy link
Copy Markdown
Collaborator

How would you like to be credited in the AUTHORS file?

@Daschle-Newberry

Copy link
Copy Markdown
Contributor Author

Sorry I didn’t get around to adding the test, my school just started and I got a bit distracted. You can use my GitHub username (First/Last). I hope I can contribute again in the future.

@chrchr-github
chrchr-github merged commit fd79f15 into cppcheck-opensource:main Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants