Skip to content

Latest commit

 

History

History
110 lines (70 loc) · 1.46 KB

observable-allocations.rst

File metadata and controls

110 lines (70 loc) · 1.46 KB

Observable Allocations

free(malloc(8));
==>
nop
malloc(0);
==>
nullptr
free(realloc(o, N))
==>
free(o);
o1 = realloc(o, 0)
// (if o1's address is not captured)
==>
free(o);
o1 = nullptr;
free(new int())
==>
unreachable
o = malloc(8);
lifetime_end(o+4, 4)
==>
o = malloc(4)
o = malloc(8);
lifetime_end(o, 4)
==>
o = malloc(4) - 4
if (o != nullptr) free(o)
==>
free(o)
allocate(N) == nullptr?
allocate(0) == allocate(0)?

Is the allocator required to return distinct addresses? Or guaranteed to fail via exception or error-val on zero sized allocation?

allocate(N) + N == allocate(M)?

Is this well defined?

If the prior example is well defined, are there limits of which objects can be compared?

allocate(N) == &global_var?
allocate(N) == &stack_var?

Which of these are well defined?

allocate(N) == cast<pointer>(0xmyconstant)?

Is this well defined?