/* >>>------------------------------------------------------------ * * File: rule_18.2.c, Module: M2CM-3.2-QAC-8.1.2 * * RULE 18.2 (Required): * An object shall not be assigned to an overlapping object. * * Implemented by messages: * 2776 Definite: Copy between overlapping objects. * * 2777 Apparent: Copy between overlapping objects. * * <<<------------------------------------------------------------ */ #include "misra.h" #include "m2cmex.h" #include "string.h" extern S16 test_1802( void ) { PC buf[100] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; (void)memcpy( &buf[ 10 ], &buf[ 20 ], 20U ); /* MISRA Violation */ u16a = 5U; (void)memcpy( &buf[ 10 ], &buf[ 20 ], u16a ); /* OK */ if (s16a > 0) { u16a = 30U; } (void)memcpy( &buf[ 10 ], &buf[ 20 ], u16a ); /* MISRA Violation */ return 1; }