Skip to content

Add check for ternary without a second operand - #4677

Closed
chrchr-github wants to merge 6 commits into
cppcheck-opensource:mainfrom
chrchr-github:chr_CrashTernary
Closed

chrchr-github wants to merge 6 commits into
cppcheck-opensource:mainfrom
chrchr-github:chr_CrashTernary

Conversation

@chrchr-github

Copy link
Copy Markdown
Collaborator

No description provided.

@danmar danmar left a comment

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.

I don't see any real danger. It's not like it will behave differently.

@chrchr-github

Copy link
Copy Markdown
Collaborator Author

Such an operator could also be created by mistake, and it's arguably harder to read. The check was actually @orbitcowboy's idea.

@orbitcowboy

Copy link
Copy Markdown
Collaborator

Such an operator could also be created by mistake, and it's arguably harder to read. The check was actually @orbitcowboy's idea.

Yes, thanks for implementing it! I still think it is worth to warn for compiler specific syntax like this.

@orbitcowboy

Copy link
Copy Markdown
Collaborator

In addition: Portability is the right section for this. If some project wants to have potable code, this warning is issued.

@chrchr-github

Copy link
Copy Markdown
Collaborator Author

There are of course numerous extensions that we could warn about: https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html

@danmar

danmar commented Jan 3, 2023 •

Copy link
Copy Markdown
Collaborator

If another compiler is used you can't compile the code. That is not dangerous. If we want to have warnings about compiler extensions I am thinking that it can be put in a addon.

I think that our portability warnings in cppcheck should typically indicate that the code might behave different on different platforms. like implementation defined behavior etc.

@chrchr-github
chrchr-github deleted the chr_CrashTernary branch February 1, 2023 14:37
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