summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextformat.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-11-25 18:21:17 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-11-26 21:02:28 (GMT)
commitd89985ce546f63f4e563ccc54951957d2f33c5ec (patch)
treedd3cf6e7b20c8a0ee6202e9d138d507829f03219 /src/gui/text/qtextformat.cpp
parent3251c5023c184466e8199c8999aa6e332eb98534 (diff)
downloadQt-d89985ce546f63f4e563ccc54951957d2f33c5ec.zip
Qt-d89985ce546f63f4e563ccc54951957d2f33c5ec.tar.gz
Qt-d89985ce546f63f4e563ccc54951957d2f33c5ec.tar.bz2
Fix strict-aliasing violation warning.
Strict aliasing is violated here, so just silence the compiler (GCC) by using an extension.
Diffstat (limited to 'src/gui/text/qtextformat.cpp')
-rw-r--r--src/gui/text/qtextformat.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index 46db253..fdbb680 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -265,10 +265,18 @@ private:
friend QDataStream &operator>>(QDataStream &, QTextFormat &);
};
-// this is only safe if sizeof(int) == sizeof(float)
+// this is only safe because sizeof(int) == sizeof(float)
static inline uint hash(float d)
{
+#ifdef Q_CC_GNU
+ // this is a GCC extension and isn't guaranteed to work in other compilers
+ // the reinterpret_cast below generates a strict-aliasing warning with GCC
+ union { float f; uint u; } cvt;
+ cvt.f = d;
+ return cvt.u;
+#else
return reinterpret_cast<uint&>(d);
+#endif
}
static inline uint hash(const QColor &color)