![]() |
![]() |
2776 | ![]() |
||||
![]() | |||||||
| Pointers | |||||||
A definite condition has been detected. A standard library function such as 'memcpy' or 'strncpy' is being used to copy data between two objects which overlap in memory. The behaviour will be undefined. It may be advisable to use the function 'memmove' instead. For example:
/*PRQA S 315,702,1253,2017,3120,3132,3408,3447,3625 ++ */
#include <string.h>
extern char buf1[10];
extern void f2776(void)
{
char * p1;
char * p2;
p1 = buf1;
p2 = &buf1[3];
(void)memcpy (p1, p2, 5); /* 2776 */
(void)memmove(p1, p2, 5); /* */
}
MISRA-C:2004 Rules applicable to message 2776:
| Rule 18.2 (Required) | An object shall not be assigned to an overlapping object. |
See also:
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |