Why does MSVC optimize away this memcpy call?

I think this is a bug in MSVC as what you are doing is legal.

Note that there has been a similar bug filed already titled: Release build with speed optimize leaves an array uninitialized.

The code given to reproduce the problem in the bug report also uses an extern type array[];

As per the team, this issue is fixed in an upcoming release (which is not mentioned).