Skip to content

Fix #13148 FN: constStatement (static_cast<void>(integer|nullptr|NULL))#8694

Open
chrchr-github wants to merge 4 commits into
cppcheck-opensource:mainfrom
chrchr-github:chr_13148
Open

Fix #13148 FN: constStatement (static_cast<void>(integer|nullptr|NULL))#8694
chrchr-github wants to merge 4 commits into
cppcheck-opensource:mainfrom
chrchr-github:chr_13148

Conversation

@chrchr-github

Copy link
Copy Markdown
Collaborator

No description provided.

ASSERT_EQUALS("", errout_str());

check("void f() { (void*)0; }");
ASSERT_EQUALS("[test.cpp:1:12]: (warning) Redundant code: Found a statement that begins with numeric constant. [constStatement]\n", errout_str());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm.. the warning message is not technically correct. I would say that the cast comes before the numeric constant.
maybe we should try to reformulate this somehow.

" (void)NULL;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:2:22]: (warning) Redundant code: Found a statement that begins with numeric constant. [constStatement]\n"
"[test.cpp:3:22]: (warning) Redundant code: Found a statement that begins with NULL constant. [constStatement]\n"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we would not say that nullptr ist a NULL constant. can we write nullptr instead or null?

"}\n");
ASSERT_EQUALS("[test.cpp:2:22]: (warning) Redundant code: Found a statement that begins with numeric constant. [constStatement]\n"
"[test.cpp:3:22]: (warning) Redundant code: Found a statement that begins with NULL constant. [constStatement]\n"
"[test.cpp:4:5]: (warning) Redundant code: Found a statement that begins with NULL constant. [constStatement]\n",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this test case it just looks like a redundant statement , I wonder if the severity should be "style" instead. Are there bugs discovered by this checker or just code cleanup?

We could change the severity in a separate PR.

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