[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
+#ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
+ 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.
Repository:
rCXX libc++
https://reviews.llvm.org/D47344
More information about the cfe-commits
mailing list