:lang: cpp

include::../rule.adoc[]

=== Exceptions

Assignments inside conditions are often the result of a mistake.
S1121 flags this potential bug.

[source,cpp,diff-id=2,diff-type=noncompliant]
----
if (x = 7) { // Noncompliant: Did the author mean "x == 7"?
  // ...
}
----

Adding a pair of parentheses to clearly state the intent is standard practice and is accepted by this rule.

[source,cpp,diff-id=2,diff-type=compliant]
----
if ((x = 7)) { // Compliant
  // ...
}
----

include::../rspecator.adoc[]
