|
|
|
|
|
by joosters
1306 days ago
|
|
The compiler didn't find UB. What it saw was a pointer dereference, followed by some code later on that checked if the pointer was null. Various optimisation phases in compilers try to establish the possible values (or ranges) of variables, and later phases can then use this to improve calculations and comparisons. It's very generic, and useful in many circumstances. For example, if the compiler can see that an integer variable 'i' can only take the values 0-5, it could optimise away a later check of 'i<10'. In this specific case, the compiler reasoned that the pointer variable could not be zero, and so checks for it being zero were pointless. |
|