[PATCH] Detect SvStream::operator<< calls with bool args w/o using -...

Stephan Bergmann (via Code Review) gerrit at gerrit.libreoffice.org
Mon Jan 21 09:34:10 PST 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/1798

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/98/1798/1

Detect SvStream::operator<< calls with bool args w/o using -Wsign-promo

...as -Wsign-promo caused other problems and has been removed again with
488823a140217e393298bc83e75084041a85ed45 "Remove -Wsign-promo."  It had
originally been introduced with e8bbb76827dd7a0e30d7d1db34a812a84d85f390 "ensure
correct export size type in stream operation," apparently to detect an
SvStream::operator<< call with a bool argument that would pick the "int"
overload instead of the "unsigned char" (aka sal_Bool) one (which would have
happened to trigger the -Wsign-promo warning "by luck," given that sal_Bool is
unsigned char and not signed char, say).

Change-Id: I0bf4389753e53a535bd90ca2a98b6a5be63d179a
---
M tools/inc/tools/stream.hxx
1 file changed, 2 insertions(+), 0 deletions(-)



diff --git a/tools/inc/tools/stream.hxx b/tools/inc/tools/stream.hxx
index abd6520..23d4a04 100644
--- a/tools/inc/tools/stream.hxx
+++ b/tools/inc/tools/stream.hxx
@@ -324,6 +324,8 @@
     SvStream&       operator<<( sal_Int32 nInt32 );
     SvStream&       operator<<( sal_Int64 nInt64 );
 
+    SvStream&       operator<<( bool b )
+    { return operator<<(static_cast< sal_Bool >(b)); }
     SvStream&       operator<<( signed char nChar );
     SvStream&       operator<<( char nChar );
     SvStream&       operator<<( unsigned char nChar );

-- 
To view, visit https://gerrit.libreoffice.org/1798
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0bf4389753e53a535bd90ca2a98b6a5be63d179a
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Stephan Bergmann <sbergman at redhat.com>



More information about the LibreOffice mailing list