22 lines
595 B
Plaintext
22 lines
595 B
Plaintext
While working with bitwise operators ``++&++`` or ``++|++`` it is easy to make a typo and write the equivalent logical operators ``++&&++`` or ``++||++``. This rule is raising issues when the right operand of a logical expression ``++&&++`` or ``++||++`` is a constant of integral type, as the developer probably meant to use the corresponding bitwise operator ``++&++`` or ``++|++``.
|
||
|
||
|
||
== Noncompliant Code Example
|
||
|
||
----
|
||
int fun(int a) {
|
||
return a || 4; // Noncompliant, did you mean to use bitwise operator '|'?
|
||
}
|
||
----
|
||
|
||
|
||
== Compliant Solution
|
||
|
||
----
|
||
int fun(int a) {
|
||
return a | 4;
|
||
}
|
||
----
|
||
|
||
|