|
|
|
|
|
by gpderetta
1306 days ago
|
|
But again, the compiler did not find UB through static analysis. The compiler inferred that the pointer could not be null and removed a redundant check. For example you would you not expect a compiler to remove a redundant bound check if it can infer that an index can't be out of range? |
|
Then it encountered evidence explicitly contradicting that assumption (a meaningless null check), and it handled it not by changing its assumption, but by quietly removing the evidence.
> For example you would you not expect a compiler to remove a redundant bound check if it can infer that an index can't be out of range?
If it can infer it from actually good evidence, sure. But using "a pointer was dereferenced" as evidence "this pointer is safe to dereference" is comically bad evidence that only the C standard could come up with.