Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 0.1.2
#1
Dear MISRA members,

I would have a question about MISRA C++:2023 Rule 0.1.2 which mentions in its rationale
"Overloaded operators are excluded from this rule because [...]"

Here, my question is whether in this scope, `operator()` should be considered to be a built-in operator.
Since to me, such one should instead be considered more of a normal function call.
Otherwise, it would undermine the rule's actual intention, which is to diagnose any unused return values of function calls, am I right?
Especially for modern C++ where plenty of code gets put into lambdas and/or std::function.

I would very happy if you could share some thoughts about this.

Thanks a lot in advance & best regards,
Stephan
Reply
#2
"Overloaded operators are excluded from this requirement" in the rationale appears to introduce a new exception, but this was not the intent - as illustrated in example f2

We plan to clarify this by changing:
"Overloaded operators are excluded from this requirement, as they should behave in the same way as built-in operators." -> to
"Calls to overloaded operators that don't use function call syntax are excluded from this requirement, as they should behave in the same way as built-in operators" reiterating the requirement in the amplification
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)