Skip to content

Fixed Qt config macro declaration - #8796

Open
Daschle-Newberry wants to merge 1 commit into
cppcheck-opensource:mainfrom
Daschle-Newberry:main
Open

Fixed Qt config macro declaration#8796
Daschle-Newberry wants to merge 1 commit into
cppcheck-opensource:mainfrom
Daschle-Newberry:main

Conversation

@Daschle-Newberry

Copy link
Copy Markdown

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.

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