From 7a273a59f73df057d2fd20fca40ae060ffbaffa3 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 6 Nov 2013 13:46:42 +0100 Subject: [PATCH] OUString::operator[] silence -Werror=strict-overflow warnings GCC 4.8.2 warns when index is a subtraction expression; the real problems in that case will be found by the "index >= 0" check. Change-Id: Iac2796badf88b7bdf6c273ddb800a8af0d3eaa6a --- include/rtl/string.hxx | 3 ++- include/rtl/ustring.hxx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx index e5ac7d6821d7..8b7eca4b34dd 100644 --- a/include/rtl/string.hxx +++ b/include/rtl/string.hxx @@ -362,7 +362,8 @@ public: @since LibreOffice 3.5 */ sal_Char operator [](sal_Int32 index) const { - assert(index >= 0 && index < getLength()); + // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2 + assert(index >= 0 && static_cast(index) < static_cast(getLength())); return getStr()[index]; } diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx index 327f455f1648..79ddfb0ca788 100644 --- a/include/rtl/ustring.hxx +++ b/include/rtl/ustring.hxx @@ -417,7 +417,8 @@ public: @since LibreOffice 3.5 */ sal_Unicode operator [](sal_Int32 index) const { - assert(index >= 0 && index < getLength()); + // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2 + assert(index >= 0 && static_cast(index) < static_cast(getLength())); return getStr()[index]; }