3 ms·
> For such inlining optimization it is the compiler that 'introduces' the UB in its intermediate step. Technically the UB is in the original code, it's the der
by masklinn 10y ago
> For such inlining optimization it is the compiler that 'introduces' the UB in its intermediate step.
Technically the UB is in the original code, it's the dereferencing of a pointer without checking it. The compiler can merely use that to assert dead code (checking for a null pointer after having already deref'd the pointer is nonsensical) and optimise it away.
- jononor 10y agoI don't support this unsafe compiler behavior. There should be a check on the pointer in sight, or a manual declaration that "this is safe, trust me". Otherwise, emit a UB warning...