MISRA Discussion Forums
Rule 0.2.4 non-compliant reason - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18)
+--- Forum: MISRA C++:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=188)
+---- Forum: 4.0 Language independent issues (https://forum.misra.org.uk/forumdisplay.php?fid=189)
+---- Thread: Rule 0.2.4 non-compliant reason (/showthread.php?tid=1676)



Rule 0.2.4 non-compliant reason - danix800 - 15-03-2024


Hi! I've questions about the examples of MISRA C++:2023 Rule 0.2.4 "Functions with limited visibility should be used at least once":


namespace B
{
  struct C2 {};
  static void swap( C2 &, C2 & ); // Non-compliant
}


B:Confusedwap() is marked as non-compliant, could anyone please give some explanations?


Thank you very much!



RE: Rule 0.2.4 non-compliant reason - misra cpp - 12-04-2024

0.2.4 is marked as a 'System' rule, meaning that the whole program needs to be considered when determining compliance.
For System rules, either the example text represents the whole of the program or it can be assumed that there are no relevant references to the example code in the rest of the program.

In the example code there are no uses of B:: swap, so it is marked as non-compliant.

In contrast, A:: swap is used in f5, so is compliant.