[libcxx-commits] [libcxx] [ASan][libc++] Annotating `std::basic_string` with all allocators (PR #75845)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Dec 19 12:24:14 PST 2023
================
@@ -1891,8 +1891,7 @@ private:
#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
const void* __begin = data();
const void* __end = data() + capacity() + 1;
- if (!__libcpp_is_constant_evaluated() && __begin != nullptr &&
- is_same<allocator_type, __default_allocator_type>::value)
+ if (!__libcpp_is_constant_evaluated() && __asan_annotate_container_with_allocator<allocator_type>::value)
----------------
EricWF wrote:
What happens when the string is created in a constant expression, and then read outside of one? LIke this?
```
#include <string>
constexpr std::string s = "abcdef";
// launder 's' through a non-constexpr function
std::string const& hide() { return s; }
/* not constinit */ std::string s2 = hide();
int main() {
return s2 == "abcdef"; // Boom?
}
```
https://godbolt.org/z/3c9K4f8cq #
https://github.com/llvm/llvm-project/pull/75845
More information about the libcxx-commits
mailing list