Comment 2 for bug 1826318

Revision history for this message
Andre Vieira (andre-simoesdiasvieira) wrote :

Hi Duane,

The removal of the 'cp2 == null' after you have dereferenced cp2 is not a bug, but a feature. The compiler uses the fact that dereferencing null is Undefined Behaviour to assume that cp2 can not be null. Since if it had been null, the program may choose to behave in any way it chooses, so not checking for null is a valid behavior.

As for the assignment to 0, I'm pretty sure it is still in the generated code, just before the jump back to .L4 there is a 'movs r0, #0' which is just that.

So I do not think any of this code-gen is wrong. I suggest you check for null first and only then dereference.