Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 8–4–4 (Required) function identifier with & or ()
#1
Is it intended to ban the use of
[code]std::cout
Reply
#2
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
<t></t>
Reply
#3
As stated, std::cout
Posted by and on behalf of
the MISRA C++ Working Group
Reply
#4
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?
};
<t></t>
Reply
#5
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
Posted by and on behalf of
the MISRA C++ Working Group
Reply
#6
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.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)