While it is technically correct to assign to parameters from within function bodies, doing so before the parameter value is read is likely a bug. Instead, initial values of parameters should be, if not treated as ``++final++``, then at least read before reassignment.

== Noncompliant Code Example

----
int glob = 0;
void function (int a, bool b) {
  if (b) {
    a = glob; // Noncompliant
  }
  otherFunction(a);
}
----

== Compliant Solution

----
int glob = 0;
void function (int a bool b) {
  int c = b ? a : glob;
  otherFunction(c);
}
----

== Exceptions

In {cpp}, pass-by-reference can sometimes be used for "out" parameters (even if using the return value of the function is most of the time a better alternative). Therefore, parameters passed by reference will be ignored by this rule.

== See

* MISRA C:2012, 17.8 - A function parameter should not be modified

ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]
