Skip to main content

IAR Embedded Workbench for RL78 5.20

MISRAC++2008-7-5-2_d (C++ only)

In this section:
Synopsis

(Required) The address of an object with automatic storage shall not be assigned to another object that may persist after the first object has ceased to exist.

Enabled by default

Yes

Severity/Certainty

High/Medium

highmedium.png
Full description

Detected a stack address stored via a reference parameter. This check is identical to MEM-stack-param-ref, MISRAC2012-Rule-1.3_s, MISRAC++2023-6.8.3_d.

Coding standards
CERT DCL30-C

Declare objects with appropriate storage durations

CWE 466

Return of Pointer Value Outside of Expected Range

MISRA C:2012 Rule-1.3

(Required) There shall be no occurrence of undefined or critical unspecified behaviour

MISRA C++ 2023 6.8.3

(Required) An assignment operator shall not assign the address of an object with automatic storage duration to an object with a greater lifetime

Code examples

The following code example fails the check and will give a warning:

void example(int *&pxx) {
  int x;
  pxx = &x;
}

The following code example passes the check and will not give a warning about this issue:

void example(int *p, int *&q) { 
  int x; 
  int *px= &x; 
  p = px; // ok, pointer
  q = p; // ok, not local 
}