Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 3-9-2 and operator overloading
#1
Dear MISRA team,

according to ISO/IEC 14882:2003 chapter 13.5.7 a single int is required to distinguish between prefix and postfix operators:

Code:
class X {
public:
X& operator++(); // prefix ++a
X operator++(int); // postfix a++
};

If you recategorize 3-9-2 as mandatory would the usage of int require a deviation or is it an explicit exception (compare with int main exception in DIR 4.6 of MISRA C 2012) ?
Thanks.
<t></t>
Reply
#2
At the moment this rule does apply to these overloads, so would require a deviation. This is under review of the next version
Posted by and on behalf of
the MISRA C++ Working Group
Reply
#3
misra cpp Wrote:At the moment this rule does apply to these overloads, so would require a deviation. This is under review of the next version
I am struggling with finding a good reason for the deviation as defined in chapter 4.4 of MISRA Compliance 2016.
I currently would choose
Quote:Usability (Recognizability)
because it´s basically about recognizing operator overloading as defined in ISO C++ 2003.
Do you agree?
Thanks.
<t></t>
Reply
#4
We'd say the reason to deviate is to ensure compliance with rule 1-0-1 (All code shall comply with the C++ standard), which in this case requires the use of int

In terms of MISRA compliance, we'd suggest Compatibility covers this
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)