﻿# V2628\. MISRA\. The pointer arguments to the Standard Library functions memcpy, memmove and memcmp should be pointers to qualified or unqualified versions of compatible types\.

This diagnostic rule is based on the [MISRA](https://misra.org.uk/) \(Motor Industry Software Reliability Association\) software development guidelines\.

This diagnostic rule is relevant only for C\.

Passing pointer arguments of incompatible types to the [`memcpy`](https://en.cppreference.com/w/c/string/byte/memcpy), [`memmove`](https://en.cppreference.com/w/c/string/byte/memmove), and [`memcmp`](https://en.cppreference.com/w/c/string/byte/memcmp) functions may be a sign of an error\.

Look at the following code example:

```cpp
void foo(int s1[CMP_SIZE], float s2[CMP_SIZE])
{
  memcpy(s1, s2, CMP_SIZE * sizeof(int));
}
```

In this example, the arguments of the `memcpy` function have different types: `s1` is `int *`, and `s2` is `float *`\. **Note**: even though the `s1` and `s2` parameters are declared as arrays, they are actually pointers due to the peculiarities of the C programming language\.

The fixed code:

```cpp
void foo(int s1[CMP_SIZE], int s2[CMP_SIZE])
{
  memcpy(s1, s2, CMP_SIZE * sizeof(int)); 
}
```