consider the following C code:
#define SIZE_A // >= SIZE_B
#define SIZE_B
#define SOME_SIZE // > SIZE_B
int main() {
int a[SIZE_A];
int b[SIZE_B] = {0};
memcpy(a, b, sizeof(int)*(SOME_SIZE));
return 0;
}
assume that SIZE_A, SIZE_B are some integers and SOME_SIZE > SIZE_B and SIZE_A>=SIZE_B. what would be the consequences if:
a. SOME_SIZE < SIZE_A
b. SOME_SIZE = SIZE_A
c. SOME_SIZE > SIZE_A
I tried to run it with some values but didn't understand if there is any constancy. Thanks
SOME_SIZE == SIZE_BandSOME_SIZE <= SIZE_Ayou don't get UB because in that case you don't read beyond the source buffer. See answer below.