Warning: file.c(212): warning: C4487E: read from variable 'config' with offset out of bounds
I'm getting this warning with the following code:
uint16_t config = 100; uint8_t configMsg[2][4]; memcpy(configMsg[0], &config, sizeof(configMsg[0]));
But I don't understand why. Anyone have any insights? It compiles w/o warning if I sub in memcpy(configMsg[0], &config, 3);
But if I sub in memcpy(configMsg[0], &config, 4); it generates the warning again.
i don't think its a good practice to do a memcpy with the size set to the sizeof (source) as you can get buffer overflows,
You're still getting buffer overflow, so that argument is somewhat silly. Just because it happens on reading instead of writing doesn't mean the buffer isn't still being overflowed.
Sorry, I was using the definition from www.owasp.org/.../Buffer_Overflow
A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold or when a program attempts to put data in a memory area past a buffer.
Maybe there is a different name for what you are talking about?