Fix MISRA C++ 2023 rule 6.4.1 "A variable declared in an inner scope shall not hide a variable declared in an outer scope"
Zserio version and language Zserio: master branch Commit hash: https://github.com/ndsev/zserio/commit/4d228036f4cb51199e151292968c8ecacc4924ce Language: C++ Priority : 5
Describe the bug Check and resolve SCA warning MISRACPP2023-6_4_1-a Identifier 'allocator' is hiding an identifier from global or namespace scope
See the attached xls for the SCA warning details MISRACPP2023-6_4_1-a_Warning_ZserioRuntime.xlsx
How to reproduce Steps to reproduce the behavior: SCA run using MISRA 2023 configuration.
Expected behavior No SCA warnings for MISRA 2023 ruleset
Additional context N.A
@Roland-Homeier @mikir FYI.
We have enabled the following SonarCloud rules:
Unfortunattely, SonarCloud have not caught anything. In spite of this, we will investigate these findings.
Please, check as well the following findings from the issue #612 which are connected to the same MISRA C++ 2023 rule.
We think that all reported issues where the identifer allocator is hiding an identifier...` are the false positives.
All others issues (identifier value, last and first) will be fixed.
Please, have a look to the following findings described by #638 and #636:
| SNo | Rule | Severity | Message | Filename | Linenumber |
|---|---|---|---|---|---|
| 1610 | MISRACPP2023-6_4_1-c | 2 | The identifier 'allocator' hides an identifier declared in class 'BitStreamReader' | /zserio_runtime/zserio/BitStreamReader.h | 312 |
| 1226 | MISRACPP2023-6_4_1-b | 2 | Identifier 'add' is hiding other identifier with the same name declared in outer scope | zserio_runtime/zserio/BitStreamWriter.cpp | 552 |
We can resolve this warning by renaming the variable names right ? Please check
We can resolve this warning by renaming the variable names right ? Please check
Probably yes. But can we agree together that these warnings are false positives?
The problem is here that there are a lot of static analyzers, each reporting different false positives. If we admit that we will blindly apply workaround for one static analyzer, we will have to find out workaround for all used analyzers. And then, we will probably end in the nevereding loop of changes without any effect. Or in another way, we will just waste our capacity with questionable result. Therefore I think that we should not try to resolve any false positive.
Actually, we think that new findings allocator in BitStreamReader.h and add in BitStreamWriter.cpp are false positives as well.