Hi, I wonder if it is possible to check enum values during assignment or comparison. As an example, attached code shows the issue. This is a common mistake that I found many times, but only few tools can detect it. gcc can't, but clang can.
Antoine
It's not hard to add a check for it.. but well unfortunately people assign wrong values by intention.
Some related tickets: https://trac.cppcheck.net/ticket/5349 https://trac.cppcheck.net/ticket/6960 https://trac.cppcheck.net/ticket/8982
Log in to post a comment.
Hi,
I wonder if it is possible to check enum values during assignment or comparison.
As an example, attached code shows the issue.
This is a common mistake that I found many times, but only few tools can detect it. gcc can't, but clang can.
Antoine
It's not hard to add a check for it.. but well unfortunately people assign wrong values by intention.
Some related tickets:
https://trac.cppcheck.net/ticket/5349
https://trac.cppcheck.net/ticket/6960
https://trac.cppcheck.net/ticket/8982