summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-05-08 10:59:27 +0200
committerMichael Stahl <mstahl@redhat.com>2012-05-08 11:31:51 +0200
commit98bced0d358927e462b1c2932d43b2a553bb847c (patch)
tree0a6ec7acdf3ff415295232f99921f6b896e703ad /oox
parent3c598c4064cffdc2c9ff19e094594ca360779b66 (diff)
oox: strict aliasing warning:
/oox/source/dump/dumperbase.cxx:345:69: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
Diffstat (limited to 'oox')
-rw-r--r--oox/source/dump/dumperbase.cxx15
1 files changed, 13 insertions, 2 deletions
diff --git a/oox/source/dump/dumperbase.cxx b/oox/source/dump/dumperbase.cxx
index 093d8c12f45a..5ad2f6a4c9b1 100644
--- a/oox/source/dump/dumperbase.cxx
+++ b/oox/source/dump/dumperbase.cxx
@@ -340,9 +340,20 @@ void StringHelper::appendHex( OUStringBuffer& rStr, sal_Int64 nData, bool bPrefi
appendHex( rStr, static_cast< sal_uInt64 >( nData ), bPrefix );
}
+static sal_uInt64
+lcl_ConvertDouble(double const f)
+{
+ sal_uInt64 i;
+ for (size_t j = 0; j < sizeof(double); ++j)
+ { // hopefully both endian independent and strict aliasing safe
+ reinterpret_cast<char *>(&i)[j] = reinterpret_cast<char const *>(&f)[j];
+ }
+ return i;
+}
+
void StringHelper::appendHex( OUStringBuffer& rStr, double fData, bool bPrefix )
{
- appendHex( rStr, *reinterpret_cast< const sal_uInt64* >( &fData ), bPrefix );
+ appendHex( rStr, lcl_ConvertDouble(fData), bPrefix );
}
// append shortened hexadecimal -----------------------------------------------
@@ -459,7 +470,7 @@ void StringHelper::appendBin( OUStringBuffer& rStr, sal_Int64 nData, bool bDots
void StringHelper::appendBin( OUStringBuffer& rStr, double fData, bool bDots )
{
- appendBin( rStr, *reinterpret_cast< const sal_uInt64* >( &fData ), bDots );
+ appendBin( rStr, lcl_ConvertDouble(fData), bDots );
}
// append formatted value -----------------------------------------------------