Hi, I've been using cppcheck in our project, and found that when calculating sizeof dereference of a 2D array in struct, cppcheck may get a wrong answer.
The logic and execution results of the 4 cases are the same, while cppcheck only reports an error on case 1, so I think this might be a bug of cppcheck.
Simply switching to case 2 can suppress this error, but I think it's better to also post it here.
Nevertheless, cppcheck has helped us a lot, thank you for your great work!
Last edit: Ricozero 2023-10-27
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
cppcheck version: 2.12.0
Hi, I've been using cppcheck in our project, and found that when calculating sizeof dereference of a 2D array in struct, cppcheck may get a wrong answer.
I reproduced this bug in the following code:
The logic and execution results of the 4 cases are the same, while cppcheck only reports an error on case 1, so I think this might be a bug of cppcheck.
Simply switching to case 2 can suppress this error, but I think it's better to also post it here.
Nevertheless, cppcheck has helped us a lot, thank you for your great work!
Last edit: Ricozero 2023-10-27
Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/12126
Last edit: CHR 2023-10-27