[PATCH] D47344: LWG 2843 "Unclear behavior of std::pmr::memory_resource::do_allocate()"

Eric Fiselier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 3 19:28:30 PDT 2018

EricWF requested changes to this revision.
EricWF added a comment.
This revision now requires changes to proceed.

Actually, I spotted a couple of issues. Requesting changes.

Comment at: src/experimental/memory_resource.cpp:29
+static bool is_aligned_to(void *ptr, size_t align)
+    void *p2 = ptr;
Wait, can't this be written `reinterpret_cast<uintptr_t>(ptr) % align == 0`?

Comment at: src/experimental/memory_resource.cpp:48
+        if (__size != 0 && !is_aligned_to(result, __align)) {
+            _VSTD::__libcpp_deallocate(result, __align);
Also, I'm not sure about the `size != 0` check. The returned pointer may be non-null and incorrectly aligned.

  rCXX libc++


More information about the cfe-commits mailing list