Page 1 of 1

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

Posted: Mon Jan 11, 2021 10:41 pm
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.

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

Posted: Wed Jan 13, 2021 4:18 pm
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 This board is not really monitored by Gimpel for error reports.