Your catch
block catches C++ exceptions. On your platform, memcpy
is not defined to throw C++ exceptions, and your compiler knows it, so it correctly informs you that your catch
block will never execute.
It's allowed for memcpy
to throw C++ exceptions. The function's behavior is undefined for cases when either of the pointers doesn't point at a valid object. It's perfectly valid for the function to throw a C++ exception in that situation because undefined behavior means it's perfectly valid for it to do anything.
You might find that memcpy
on your platform throws OS exceptions when you're reading or writing invalid memory. You could get an access violation, but the C++ catch
block doesn't catch that kind of exception. Use __try
and __except
for that. Better yet, analyze and edit your program to make sure you never get into such a situation in the first place. Then you don't have to worry about how any particular platform behaves.