3 ms·
We're only considering UB conditions here, not errors in general that may be impossible to detect. Every UB condition can be detected by the compiler because, a
by coliveira 3y ago
We're only considering UB conditions here, not errors in general that may be impossible to detect. Every UB condition can be detected by the compiler because, after all, the compiler needs to check for UB to generate code. All it takes is for the compiler to generate warning/errors when this occurs. If this is not done by your compiler, ask them to add this feature instead of just complaining about UB in general.
- UncleMeat 3y agoAll of the things I described are UB.
- dureuill 3y ago> , after all, the compiler needs to check for UB to generate code. No the compiler does not check for UB to generate code. A lot of UB (runtime out of bounds, use after free) are very difficult to detect statically (at least without specialized annotations). The compiler applies transformations to the code that are valid (in the sense that they produce an equivalent program) only in the absence of UB. So if the input program contains UB, the transformed program produced by the compiler may or may not be valid