[all-commits] [llvm/llvm-project] ffcb0a: [libc++] Update polymorphic_allocator to never con...

Nikolas Klauser via All-commits all-commits at lists.llvm.org
Wed Jul 16 01:04:19 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ffcb0a4559b850c5ba51003ae1877c7c2ae9836f
      https://github.com/llvm/llvm-project/commit/ffcb0a4559b850c5ba51003ae1877c7c2ae9836f
  Author: Nikolas Klauser <nikolasklauser at berlin.de>
  Date:   2025-07-16 (Wed, 16 Jul 2025)

  Changed paths:
    M libcxx/include/__memory_resource/polymorphic_allocator.h
    A libcxx/test/libcxx/mem/mem.res/ctor.nullptr.assert.pass.cpp
    A libcxx/test/libcxx/mem/mem.res/nonnull.verify.cpp
    M libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/resource.pass.cpp
    M libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/select_on_container_copy_construction.pass.cpp

  Log Message:
  -----------
  [libc++] Update polymorphic_allocator to never contain a nullptr (#148423)

According to `[mem.poly.allocator.ctor]` the pointer contained in
`polymorphic_allocator` can never be null. The default constructor uses
`get_default_resource()`, which never returns null and the constructor
taking a pointer explicitly has a precondition that the pointer is
non-null.

This patch adds a warning and an assertion in case a user passes a null
pointer to `polymorphic_allocator` as well as marking `resource()` to
never return null.

This also fixes some tests which contained UB.

Fixes #148420



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list