Re:Falsehoods programmers believe about undefined behavior
by olliej on Monday November 28, 2022 @11:38AM
(#33775780)
memset, memcpy, and memmove, etc all depend on UB.
memset and memcpy read and write padding bytes, which is UB. If you try to say memset/cpy is a "primitive operation", then you're still stuck with the "correct" struct initialization (memset, bzero) being UB if you did something like:
memset and memcpy read and write padding bytes, which is UB. If you try to say memset/cpy is a "primitive operation", then you're still stuck with the "correct" struct initialization (memset, bzero) being UB if you did something like:
The ludicrously broad definition of what UB apparent allows, this can be "optimized" to Because bzero() writes to padding, and that is UB, which means the condition==true branch "can't happen" \o/memmove falls to UB much requires pointer comparisons between pointers to different objects, which is UB.