[all-commits] [llvm/llvm-project] b8608b: [libc++] Use addressof in assignment operator.

mordante via All-commits all-commits at lists.llvm.org
Thu Oct 7 09:11:00 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b8608b87239ca7817d1536376a8ce4b5265747ee
      https://github.com/llvm/llvm-project/commit/b8608b87239ca7817d1536376a8ce4b5265747ee
  Author: Mark de Wever <koraq at xs4all.nl>
  Date:   2021-10-07 (Thu, 07 Oct 2021)

  Changed paths:
    M libcxx/include/__hash_table
    M libcxx/include/__tree
    M libcxx/include/deque
    M libcxx/include/forward_list
    M libcxx/include/list
    M libcxx/include/map
    M libcxx/include/unordered_map
    M libcxx/include/valarray
    M libcxx/include/vector
    A libcxx/test/std/containers/associative/map/map.cons/copy_assign.addressof.compile.pass.cpp
    A libcxx/test/std/containers/associative/multimap/multimap.cons/copy_assign.addressof.compile.pass.cpp
    A libcxx/test/std/containers/associative/multiset/multiset.cons/copy_assign.addressof.compile.pass.cpp
    A libcxx/test/std/containers/associative/set/set.cons/copy_assign.addressof.compile.pass.cpp
    A libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_copy.addressof.compile.pass.cpp
    A libcxx/test/std/containers/container.adaptors/queue/queue.defn/assign_copy.addressof.compile.pass.cpp
    A libcxx/test/std/containers/sequences/array/array.cons/implicit_copy.addressof.compile.pass.cpp
    A libcxx/test/std/containers/sequences/deque/deque.cons/move_assign.addressof.compile.pass.cpp
    A libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_copy.addressof.compile.pass.cpp
    A libcxx/test/std/containers/sequences/list/list.cons/assign_copy.addressof.compile.pass.cpp
    A libcxx/test/std/containers/sequences/vector/vector.cons/assign_copy.addressof.compile.pass.cpp
    A libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.addressof.compile.pass.cpp
    A libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.addressof.compile.pass.cpp
    A libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.addressof.compile.pass.cpp
    A libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/assign_copy.addressof.compile.pass.cpp
    A libcxx/test/std/numerics/numarray/template.valarray/valarray.assign/value_assign.addressof.compile.pass.cpp
    A libcxx/test/support/operator_hijacker.h

  Log Message:
  -----------
  [libc++] Use addressof in assignment operator.

Replace `&__rhs` with `_VSTD::addressof(__rhs)` to guard against ADL hijacking
of `operator&` in `operator=`. Thanks to @CaseyCarter for bringing it to our
attention.

Similar issues with hijacking `operator&` still exist, they will be
addressed separately.

Reviewed By: #libc, Quuxplusone, ldionne

Differential Revision: https://reviews.llvm.org/D110852




More information about the All-commits mailing list