There are also a lot of things in C++ that are valid syntax but that you are not allowed to do and invoke undefined behaviour. The compiler is not required to flag such issues, you have to know all the rules and abide by them. If any part of your code contains UB, the compiler has no obligation to generate anything sensible for any parts of your program.
仅仅因为程序编译并不意味着它没有错误。它仅表示它在语法上有效。
编译器无法了解您的意图,因此显然无法标记代码中的任何逻辑错误。
There are also a lot of things in C++ that are valid syntax but that you are not allowed to do and invoke undefined behaviour. The compiler is not required to flag such issues, you have to know all the rules and abide by them. If any part of your code contains UB, the compiler has no obligation to generate anything sensible for any parts of your program.
就正确性而言,可以编译的东西几乎没有任何意义。这是一个非常低的酒吧。