[PATCH] write double/float via union with unsigned type for strict-a...

Caolán McNamara (via_Code_Review) gerrit at gerrit.libreoffice.org
Tue Feb 5 02:26:11 PST 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/1990

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/90/1990/1

write double/float via union with unsigned type for strict-aliasing

Change-Id: Ie4dd1d41e5cde27ec5b144ca4b7c97276ff62479
---
M registry/tools/reg2bin.cxx
1 file changed, 2 insertions(+), 12 deletions(-)



diff --git a/registry/tools/reg2bin.cxx b/registry/tools/reg2bin.cxx
index be8fead..5983b56 100644
--- a/registry/tools/reg2bin.cxx
+++ b/registry/tools/reg2bin.cxx
@@ -1196,6 +1196,7 @@
                         static_cast< sal_uInt32 >(j->second.constantValue.l));
                     break;
                 case CONSTANT_TYPE_UNSIGNED_LONG:
+                case CONSTANT_TYPE_FLOAT: //access through union for strict-aliasing
                     write32(file, j->second.constantValue.ul);
                     break;
                 case CONSTANT_TYPE_HYPER:
@@ -1204,19 +1205,8 @@
                         static_cast< sal_uInt64 >(j->second.constantValue.h));
                     break;
                 case CONSTANT_TYPE_UNSIGNED_HYPER:
+                case CONSTANT_TYPE_DOUBLE: //access through union for strict-aliasing
                     write64(file, j->second.constantValue.uh);
-                    break;
-                case CONSTANT_TYPE_FLOAT:
-                    write32(
-                        file,
-                        *reinterpret_cast< sal_uInt32 const * >(
-                            &j->second.constantValue.f));
-                    break;
-                case CONSTANT_TYPE_DOUBLE:
-                    write64(
-                        file,
-                        *reinterpret_cast< sal_uInt64 const * >(
-                            &j->second.constantValue.d));
                     break;
                 default:
                     std::abort(); // this cannot happen

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie4dd1d41e5cde27ec5b144ca4b7c97276ff62479
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Caolán McNamara <caolanm at redhat.com>


More information about the LibreOffice mailing list