|
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.
|