Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 2-10-5 is totaly ambiguous
#1
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.
<t></t>
Reply
#2
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
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)