Skip to main content

IAR Embedded Workbench for RX 5.20

MISRAC2012-Rule-21.15

In this section:
Synopsis

(Required) The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types.

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

The pointer arguments to memcpy, memmove and memcmp have different types.

Coding standards
MISRA C:2012 Rule-21.15

(Required) The pointer arguments to the Standard Library function memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types

Code examples

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

/*
 * Is it intentional to only copy part of 's2'?
 */
void f(uint8_t s1[8], uint16_t s2[8])
{
  (void) memcpy(s1, s2, 8);
}

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

/*
 * Is it intentional to only copy part of 's2'?
 */
void f(uint8_t s1[8], uint8_t s2[8])
{
  (void) memcpy(s1, s2, 8);
}