From f1d6232f39e3c451a0f29e993df9040b0128cbd9 Mon Sep 17 00:00:00 2001 From: Mikhail Kashkarov Date: Mon, 7 May 2018 19:35:33 +0300 Subject: Align internal representation in cow-string by 8. COW-strings are used as an exception strings still (yet), and since char buffer starts at "this + 1" ("this" in COW basic_string<>), where "this" is properly aligned, sizeof(*this) may be not aligned by 8 (12 bytes under i686 arch with current compiler), so asan annotations will fail. Still testing with all configurations. Change-Id: Ic7bb665a58d22f7e8ab979fc548fc96973473f32 --- libstdc++-v3/include/bits/basic_string.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index 7a899c16dd7..8c353771ec6 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -3010,7 +3010,12 @@ _GLIBCXX_END_NAMESPACE_CXX11 size_type _M_length; size_type _M_capacity; _Atomic_word _M_refcount; - }; + } +#ifdef _GLIBCXX_HAS_ASAN + __attribute__((aligned(8))); +#else + ; +#endif struct _Rep : _Rep_base { -- cgit v1.2.3