Hi, my team is reporting what they believe are false positives for rule C:M23_053 (“The source code used to implement an entity shall appear only once”).
The rule description states that it is part of MISRA C++:2023. I also noted that this same rule is implemented for both C, C++ and Objective-C and they all refer to the same MISRA C++ reference.
However, the C language has its own MISRA rules. One rule in particular from the C guidelines — “An external object or function shall be declared once in one and only one file” — appears to contradict the C++ rule when weak symbols are involved.
Specifically, the C rule states that it:
Ignores compiler‑specific, non‑portable ways of overriding function declarations, such as
#pragma weakor__attribute__((weak)).
To me, this MISRA C++ rule should probably be removed and replaced with the corresponding MISRA C rule. What are your thoughts?
Some relevant references:
https://se.mathworks.com/help/bugfinder/ref/misracpp2023rule6.2.3.html
https://se.mathworks.com/help/bugfinder/ref/misrac2023rule8.5.html