[Libreoffice-commits] core.git: include/com

Michael Stahl mstahl at redhat.com
Thu Apr 24 04:03:28 PDT 2014


 include/com/sun/star/uno/Sequence.hxx |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit c1158fbc1c8abb0842fb8eb307724ef42ac6e8e2
Author: Michael Stahl <mstahl at redhat.com>
Date:   Thu Apr 24 12:57:26 2014 +0200

    Sequence::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: I4c3f0bdb7996e433b1693eb7dcbafb9610b5dbcf

diff --git a/include/com/sun/star/uno/Sequence.hxx b/include/com/sun/star/uno/Sequence.hxx
index 748fdcb..88fba66 100644
--- a/include/com/sun/star/uno/Sequence.hxx
+++ b/include/com/sun/star/uno/Sequence.hxx
@@ -156,7 +156,8 @@ template<class E> E const * Sequence<E>::end() const
 template< class E >
 inline E & Sequence< E >::operator [] ( sal_Int32 nIndex )
 {
-    assert( nIndex >= 0 && nIndex < getLength() );
+    // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
+    assert(nIndex >= 0 && static_cast<sal_uInt32>(nIndex) < getLength());
     return getArray()[ nIndex ];
 }
 
@@ -164,7 +165,8 @@ template< class E >
 inline const E & Sequence< E >::operator [] ( sal_Int32 nIndex ) const
     SAL_THROW(())
 {
-    assert( nIndex >= 0 && nIndex < getLength() );
+    // silence spurious -Werror=strict-overflow warnings from GCC 4.8.2
+    assert(nIndex >= 0 && static_cast<sal_uInt32>(nIndex) < getLength());
     return reinterpret_cast< const E * >( _pSequence->elements )[ nIndex ];
 }
 


More information about the Libreoffice-commits mailing list