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
This commit is contained in:
Michael Stahl 2013-11-06 13:46:42 +01:00
parent b5aa7f71e6
commit 7a273a59f7
2 changed files with 4 additions and 2 deletions

View File

@ -362,7 +362,8 @@ public:
@since LibreOffice 3.5 @since LibreOffice 3.5
*/ */
sal_Char operator [](sal_Int32 index) const { 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<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
return getStr()[index]; return getStr()[index];
} }

View File

@ -417,7 +417,8 @@ public:
@since LibreOffice 3.5 @since LibreOffice 3.5
*/ */
sal_Unicode operator [](sal_Int32 index) const { 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<sal_uInt32>(index) < static_cast<sal_uInt32>(getLength()));
return getStr()[index]; return getStr()[index];
} }