05-04-2022, 12:34 PM
(This post was last modified: 06-04-2022, 07:07 AM by Tobias Loose.)
Hi!
The rule states
The code checker we employ also flags the usage of these operators in expressions that contain member-access operators, subscript operators, and the like.
The rationale and example appear to focus on other arithmetic operators, which makes sense.
Is this an oversight in the rule formulation (missing "arithmetic"), or is the following intentionally non-compliant with 5-2-10?
Thanks!
The rule states
Quote:The increment (++) and decrement (--) operators should not be mixed with other operators in an expression.
The code checker we employ also flags the usage of these operators in expressions that contain member-access operators, subscript operators, and the like.
The rationale and example appear to focus on other arithmetic operators, which makes sense.
Is this an oversight in the rule formulation (missing "arithmetic"), or is the following intentionally non-compliant with 5-2-10?
Code:
void foo()
{
struct A { int b; };
A a{0};
a.b++; // Non-compliant
int c[3] = {1, 2, 3};
c[2]++; // Non-compliant
A* const a_ptr = &a;
a_ptr->b++; // Non-compliant
}
Thanks!