Debug notes (Update: Valgrind: Conditional jump or move depends on uninitialized value(s))

Valgrind: Conditional jump or move depends on uninitialized value(s)

The example given there is easy to understand, but I encountered a less obvious one when writing a function to add a node to a linked list:

Valgrind reports an error here because after allocating space for p->next, that space is not assigned (i.e. not initialized), and then p = p->next is executed, which effectively jumps to an uninitialized location.

It should be changed to:

Same hashcode

This hashCode() function produces the same hashCode; 256 = 2^8, and after multiplying several times it will overflow, so the hashCode depends on the last few elements of the array.

Last updated