3 ms·
Most of the complaints about UB-based optimization that I've seen are from when the compiler uses UB to assume some type restraint that the programmer wishes it
by mnarayan01 9y ago
Most of the complaints about UB-based optimization that I've seen are from when the compiler uses UB to assume some type restraint that the programmer wishes it did not. E.g.:
int v = *p;
if (p == NULL) { /* ... */ }
The compiler uses UB to annotate the type information on p to indicate it's non-null, and then performs type-directed optimization.
- posterboy 9y ago> then performs type-directed optimization. which can mean erasure of the if block, to be perfectly clear here. edit: any good compiler will warn about the assignment or throw an error, though, using the right compiler options.