MISRA Discussion Forums
Rule 8–4–4 (Required) function identifier with & or () - 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.8 Declarators (C++) (https://forum.misra.org.uk/forumdisplay.php?fid=137)
+---- Thread: Rule 8–4–4 (Required) function identifier with & or () (/showthread.php?tid=1099)



Rule 8–4–4 (Required) function identifier with & or () - Achim Olaf Zacher - 13-08-2014

Is it intended to ban the use of
[code]std::cout


Re: Rule 8–4–4 (Required) function identifier with & or () - roberto - 07-07-2016

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


Re: Rule 8–4–4 (Required) function identifier with & or () - misra cpp - 31-10-2016

As stated, std::cout


Re: Rule 8–4–4 (Required) function identifier with & or () - grunwald - 01-12-2016

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?
};


Re: Rule 8–4–4 (Required) function identifier with & or () - misra cpp - 24-01-2017

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


RE: Rule 8–4–4 (Required) function identifier with & or () - misra cpp - 22-07-2021

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.