MISRA Discussion Forums
Rule 2-10-5 is totaly ambiguous - 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++:2008 rules (https://forum.misra.org.uk/forumdisplay.php?fid=19)
+---- Forum: 6.2 Lexical conventions (C++) (https://forum.misra.org.uk/forumdisplay.php?fid=131)
+---- Thread: Rule 2-10-5 is totaly ambiguous (/showthread.php?tid=1246)



Rule 2-10-5 is totaly ambiguous - udi - 15-05-2016

Hello,

I think this rule should be rephrased (or maybe split) for clarity, and giving some more examples.
Problems are:
1. As already mentioned - function overloading.

2. It is not clear whether static variables inside function are violating this rule:
void f1() { static int nFoo; }
void f2() { static int nFoo; }
I think it does not violate (also based on my exmaples from MISRA C-2012 Rule 5.9) but my static analysis tool, thinks it does.

3. Do static class members violate this rule?
class C1 { public: static int nNumOfItems; }
class C2 { public: static int nNumOfItems; }
I think it does not.

To my understanding, this rule comes to cover 2 cases (which should be properly explained in the rationale):
1. Hiding of identifier in an internal scope
2. Conusion of 2 global static identifiers with the same name (whose scope is actualy indipendantly limited to each .cpp file)

Thanks,
Udi.


Re: Rule 2-10-5 is totaly ambiguous - misra cpp - 11-10-2016

Your examples 2 and 3 are both violations of this rule (function overloading is the subject of a different topic)

This will be addressed by a planned Technical Corrigendum, where all your examples will be made compliant