Hello. Just found a little issue. Take the following code snippet:
void foo(int c[]) {
int &cc = c[0];
cc &= ~0xff;
}
then run cppcheck on that using --enable=all, this style warning appears:
style: Variable 'cc' is assigned a value that is never used. [unreadVariable]
int &cc = c[0];
Here the assignment through the reference has actual use, so this seems like a false positive. Also, if using a pointer instead of a reference to get the same effect, then cppcheck doesn't complain.
using cppcheck 2.6.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello. Just found a little issue. Take the following code snippet:
then run cppcheck on that using --enable=all, this style warning appears:
style: Variable 'cc' is assigned a value that is never used. [unreadVariable]
int &cc = c[0];
Here the assignment through the reference has actual use, so this seems like a false positive. Also, if using a pointer instead of a reference to get the same effect, then cppcheck doesn't complain.
using cppcheck 2.6.
Thanks for reporting, Daniel has created a ticket here: https://trac.cppcheck.net/ticket/10597