summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qhash.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-12-03 09:32:06 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-12-03 17:15:32 (GMT)
commitd7b34583926e3bd751120a4b827cd5ba6667dea3 (patch)
treeeaf9cb8e9392d26f36e4129401485f8e8237e518 /src/corelib/tools/qhash.h
parente2e0b8d13ba045c693a03c818157f952488c72bd (diff)
downloadQt-d7b34583926e3bd751120a4b827cd5ba6667dea3.zip
Qt-d7b34583926e3bd751120a4b827cd5ba6667dea3.tar.gz
Qt-d7b34583926e3bd751120a4b827cd5ba6667dea3.tar.bz2
Fix Run-Time Check Failure with MSVC when downcasting.
When you cast from a 64-bit type to a 32-bit one, MSVC produces an RTCF, despite the explicit cast. The solution is to add & 0xFFFFFFFF. Task-number: QTBUG-4255 Reviewed-by: Marius Storm-Olsen
Diffstat (limited to 'src/corelib/tools/qhash.h')
-rw-r--r--src/corelib/tools/qhash.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 1918229..2de03dc 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -69,18 +69,18 @@ inline uint qHash(int key) { return uint(key); }
inline uint qHash(ulong key)
{
if (sizeof(ulong) > sizeof(uint)) {
- return uint((key >> (8 * sizeof(uint) - 1)) ^ key);
+ return uint(((key >> (8 * sizeof(uint) - 1)) ^ key) & (~0U));
} else {
- return uint(key);
+ return uint(key & (~0U));
}
}
inline uint qHash(long key) { return qHash(ulong(key)); }
inline uint qHash(quint64 key)
{
if (sizeof(quint64) > sizeof(uint)) {
- return uint((key >> (8 * sizeof(uint) - 1)) ^ key);
+ return uint(((key >> (8 * sizeof(uint) - 1)) ^ key) & (~0U));
} else {
- return uint(key);
+ return uint(key & (~0U));
}
}
inline uint qHash(qint64 key) { return qHash(quint64(key)); }