Maybe, if operating under a lot of restrictions and using theorem proof, but even then the compiler and the OS (and the CPU) also need to be bug-free for complete protection.
Compilers have plenty of bugs, so do operating systems and CPUs as we have seen in recent years.
Compilers have plenty of bugs, so do operating systems and CPUs as we have seen in recent years.