MISRA C++:2008 Rule 7-1-1 vs. Note 952

PC-lint Plus User Discussion
Post Reply
coder

MISRA C++:2008 Rule 7-1-1 vs. Note 952

Post by coder »

Rule 7–1–1 (Required) states "A variable which is not modified shall be const qualified"
PC-lint Plus issues note 952 (as a violation of rule 7-1-1) for function parameters including array[] or const array[].
However in C++, array[] or const array[], cannot be qualified also as array[const] as in C99.

Technically, note 952 should not be issued for array[].

Note, that the obvious workaround of replacing array[] with *const array, is not really a solution
as it triggers note 9016 (performing pointer arithmetic via addition/subtraction) in most cases
for violation of MISRA C++ required Rule 5-0-15 (Array indexing shall be the only form of pointer
arithmetic), when the array is accessed via [ ] which is incompatible with the pointer declaration
according to MISRA and their very vivid examples.

So, due to the MISRA ill-conceived mutually exclusive rules, one has to pollute the code with
numerous lint -esym(952, ...) suppression for array parameters or suppress -e952 globally,
which is clearly not the right solution.
Michael Metivier

Re: MISRA C++:2008 Rule 7-1-1 vs. Note 952

Post by Michael Metivier »

Questions about message generation or suggestions for changes to the way that certain messages are generated/not generated should probably be directed to Gimpel's support line at support@gimpel.com. This board is not really monitored by Gimpel for error reports.
Post Reply