Firstly, C++ has enough degrees of freedom that a computer cannot make it completely safe. C++ literally gives you full access to anything the CPU can do.
Functions like fscanf are just routines that do looping and checking internally to give you higher-level functionality. However, fscanf has no knowledge of how far a buffer goes (I.e. how big it is). The only part of the code that does have that information is the malloc library, but that's also just a higher-level algorithm to make things easier that the hardware doesn't know about.
Theoretically, the compiler can store this information and pass it to the MPX extensions, but in many applications that will be nearly impossible to do because most things are stored as void*
and passed around manually so a static analyzer cannot have the requisite information to set those registers. The only way to do this would be to store additional information at runtime, thereby changing the size of void*
which would violate the rules of C++, so it would have to be a special type that very few developers will actually implement because it will cost too much.
A buffer overflow happens when the developer is lazy with their power, not when the hardware messes up.
This is just one of the possible bugs in software that make it insecure. There have been SEVERAL bugs which are integer overflows, invalid logic, etc.
So no, it will not make C++ completely safe to use - nothing will.