[Libreoffice-commits] core.git: include/rtl
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jul 19 20:48:12 UTC 2021
include/rtl/string.hxx | 1 +
include/rtl/ustring.hxx | 1 +
2 files changed, 2 insertions(+)
New commits:
commit e1af6fefa0f0b919ccdacc9edfbae034e6347d46
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Mon Jul 19 21:11:51 2021 +0200
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Mon Jul 19 22:47:36 2021 +0200
offsetof is only guaranteed to work with standard layout types
Change-Id: If9ba41a219d3c3b5bff838104b9a0df53030b8f5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119181
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
index f80dd7410da7..1f3120e7b4e5 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -129,6 +129,7 @@ private:
static constexpr void assertLayout() {
// These static_asserts verifying the layout compatibility with rtl_String cannot be class
// member declarations, as offsetof requires a complete type, so defer them to here:
+ static_assert(std::is_standard_layout_v<OStringLiteral>);
static_assert(offsetof(OStringLiteral, str.refCount) == offsetof(OStringLiteral, more.refCount));
static_assert(offsetof(OStringLiteral, str.length) == offsetof(OStringLiteral, more.length));
static_assert(offsetof(OStringLiteral, str.buffer) == offsetof(OStringLiteral, more.buffer));
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index 2699c09ac03f..96bb504f77a8 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -110,6 +110,7 @@ private:
static constexpr void assertLayout() {
// These static_asserts verifying the layout compatibility with rtl_uString cannot be class
// member declarations, as offsetof requires a complete type, so defer them to here:
+ static_assert(std::is_standard_layout_v<OUStringLiteral>);
static_assert(offsetof(OUStringLiteral, str.refCount) == offsetof(OUStringLiteral, more.refCount));
static_assert(offsetof(OUStringLiteral, str.length) == offsetof(OUStringLiteral, more.length));
static_assert(offsetof(OUStringLiteral, str.buffer) == offsetof(OUStringLiteral, more.buffer));
More information about the Libreoffice-commits
mailing list