MISRA Discussion Forums

Full Version: Rule 8–4–4 (Required) function identifier with & or ()
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is it intended to ban the use of
[code]std::cout
The rationale of the rule clearly explains that what has to be avoided is the possible mistake where
Code:
if ( f ) { ... }
is written where
Code:
if ( f() ) { ... }
was intended. The former fragment compiles because of an implicit conversion to pointer (decay) and boolean evaluation.

In order to achieve this effect, the rule is so strict that (if interpreted literally) would ban the idiomatic
[code]
std:cout
As stated, std::cout
Here's another case that seems like a violation by the current formulation of 8-4-4 (though it clearly shouldn't be):

class DerivedClass : private BaseClass
{
public:
using BaseClass::getValue; // 8.4.4 violation?
};
Currently we are thinking as the following as exception to this rule in the TC
- Passing the function by reference or assigning it to a reference object,
- Use of the name in a 'using declaration'
- Use of iostream items for formatted output, like std::endl
Note:  this post was originally made by chenzhuowansui, but was lost when the bulletin board was migrated to the new website
          restored by  misra cpp

Unread post by chenzhuowansui » Tue Jun 22, 2021 3:04 am

Hi there,

May i know when this TC will be released? Currently we are asked to make adjustments to our checker of this rule, but we don't want to unless the TC is released(or the changes to this rule are almost finalized), as we don't want to change the checker back and forth...

Thanks!

We are currently working on a complete update to the rules, the release date for which is TBD. This means we are unlikely to produce a TC for 2008

I can say that the equivalent rule to 8-4-4 in the new version does allow the situations you raised as an issue in the old version.