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

Post a reply


This question is a means of preventing automated form submissions by spambots.

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is OFF
Smilies are OFF

Topic review
   

Expand view Topic review: MISRA C++:2008 Rule 7-1-1 vs. Note 952

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

by Michael Metivier » Wed Jan 13, 2021 4:18 pm

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.

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

by coder » Mon Jan 11, 2021 10:41 pm

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.

Top