C/C++ compilers are designed to turn C/C++ into machine code.
They are not designed to check your code for logic errors.
Checking your code for logic errors would greatly increase compile time. Its also a really, really hard problem for a computer to solve. Checking your code for type errors is easy.