Rule 2-10-5 is totaly ambiguous

Moderators: david ward, misra cpp

Post Reply
udi
Posts: 9
Joined: Wed May 11, 2016 8:24 am
Company: Elbit

Rule 2-10-5 is totaly ambiguous

Post by udi » Sun May 15, 2016 6:36 am

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.

misra cpp
Posts: 150
Joined: Mon Jun 02, 2008 1:55 pm
Company: MISRA

Re: Rule 2-10-5 is totaly ambiguous

Post by misra cpp » Tue Oct 11, 2016 10:16 am

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

Post Reply

Return to “6.2 Lexical conventions (C++)”