On Sat Feb 11 14:59:52 2023 +0000, Jinoh Kang wrote:
Can we avoid arithmetic on NULL pointer? It is undefined behavior, since it does not point to a valid object.[^note]
struct bin *bin; struct block *block; if (!heap->bins) return STATUS_UNSUCCESSFUL; bin = heap->bins + BLOCK_SIZE_BIN( block_size ); if (bin == heap->bins + BLOCK_SIZE_BIN_COUNT - 1) return STATUS_UNSUCCESSFUL;
They could've made the result undefined, and in this case this would be free of UB, but instead they decided that even an unused computation can trigger undefined behavior if the operation is undefined behavior... I don't get it.