2-10-2 "block scope" for classes and namespaces - 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: 2-10-2 "block scope" for classes and namespaces (/showthread.php?tid=1470) |
2-10-2 "block scope" for classes and namespaces - abgs - 14-02-2019 Rule 2-10-2 is defined in terms of "block scopes" and "nested blocks". The only example is of a function and there is no mention of classes nor namespaces. Does "block" refer only to a compound statement as part of a function body, or is the intention to include other curly-brace-enclosed regions or scopes? For example, are any of the indicated lines violations of rule 2-10-2? Code: int i; Re: 2-10-2 "block scope" for classes and namespaces - misra cpp - 10-04-2019 2-10-2 is not purely about block scopes, so your examples A, B, C and D are violations of this rule, but E isn’t as a derived class is not an inner scope with respect to the base. |