4 ms·
"or the behavior is as if the size were some nonzero value, except that the returned pointer shall not be used to access an object" I love the C standards. Is
by mcguire 12y ago
"or the behavior is as if the size were some nonzero value, except that the returned pointer shall not be used to access an object"
I love the C standards. Is that defining the behavior of malloc or the behavior of the code calling malloc?
- pbsd 12y agoThe caller code. It is saying that the caller cannot dereference the returned pointer, under pain of undefined behavior.
- AnimalMuppet 12y agoIn particular, you can't access (read or write) off either end of an allocated block. Well, if the block is of (nominal) length 0, there is nowhere to access safely.