[libcxx-commits] [PATCH] D101638: [libc++] std::to_address mustn't depend on P::element_type.

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon May 3 12:59:28 PDT 2021

zoecarver added a subscriber: EricWF.
zoecarver added inline comments.

Comment at: libcxx/test/std/utilities/memory/pointer.conversion/to_address_std_iterators.pass.cpp:32
+    assert(std::to_address(c.begin()) == c.data());
+    assert(std::to_address(c.end()) == c.data() + c.size());
+    assert(std::to_address(cc.begin()) == cc.data());
zoecarver wrote:
> @Quuxplusone this is the reason the test is failing in debug mode, we can't dereference end. Do we ever really want to be dereferencing end anyway, isn't that UB? I don't think we need to test this, at least not in debug mode. 
Actually on second thought: we're not actually dereferencing anything here. I guess when the assertion was added to `operator->` they didn't expect the caller of the operator to be using the pointer itself. So I feel like there's a good argument to remove the assertion all together. @EricWF, thoughts?

  rG LLVM Github Monorepo



More information about the libcxx-commits mailing list