[libcxx-commits] [PATCH] D136765: [ASan][libcxx] Annotating std::vector with all allocators

Anton Bikineev via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 7 05:59:37 PST 2023


AntonBikineev added a comment.

Regarding the Standard terms, accessing destructed, but not released memory is well defined in basic.life#6 <https://eel.is/c++draft/basic.life#6> (in some limited ways, but exactly sufficient for the allocator needs):

  after the lifetime of an object has ended and before the storage which the object occupied is reused or released, any pointer that represents the address of the storage location where the object will be or was located may be used but only in limited ways. ... such a pointer refers to allocated storage ([basic.stc.dynamic.allocation]), and using the pointer as if the pointer were of type void* is well-defined. Indirection through such a pointer is permitted...



> Since you never run the destructor the object is still within it's lifetime, i.e. you create multiple objects within the same memory region, which is UB.

Even that may (suprisingly) be well-defined (as the paragraph above <https://eel.is/c++draft/basic.life#5> mentions):

  A program may end the lifetime of an object of class type without invoking the destructor, by reusing or releasing the storage as described above.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136765/new/

https://reviews.llvm.org/D136765



More information about the libcxx-commits mailing list