Hi,
cppcheck didn't detect this problem (neither gcc or clang):
int f( unsigned char TryThis ) { return TryThis >> 8; }
Integer promotion is causing this to be valid but this caused a bug in our system and was not detected until it reached the field.
Worth to add a small test for this ?
yes. as you say, it's valid so we can only write some "always 0" warning. that seems helpful. Thanks for your suggestion.
I created this ticket: https://trac.cppcheck.net/ticket/9503
If you are interested.. feel free to investigate this. Probably it would be good if ValueFlow says that the result is always 0.
I will give it a try.
Thanks
Log in to post a comment.
Hi,
cppcheck didn't detect this problem (neither gcc or clang):
Integer promotion is causing this to be valid but this caused a bug in our system and was not detected until it reached the field.
Worth to add a small test for this ?
yes. as you say, it's valid so we can only write some "always 0" warning. that seems helpful. Thanks for your suggestion.
I created this ticket:
https://trac.cppcheck.net/ticket/9503
If you are interested.. feel free to investigate this. Probably it would be good if ValueFlow says that the result is always 0.
I will give it a try.
Thanks