summaryrefslogtreecommitdiff
path: root/src/jit/valuenum.h
diff options
context:
space:
mode:
authorPat Gavlin <pagavlin@microsoft.com>2016-02-26 16:48:47 -0800
committerPat Gavlin <pagavlin@microsoft.com>2016-02-26 16:48:47 -0800
commited690e0a669cf3c62588c3cbc9d5012490cee1c3 (patch)
tree7b06f5632999d8f31a2e8cc1ed6d81fa82a45a64 /src/jit/valuenum.h
parent9ab9bcb2ffba27b8b5b75d23cc14095bd3e6d5b1 (diff)
downloadcoreclr-ed690e0a669cf3c62588c3cbc9d5012490cee1c3.tar.gz
coreclr-ed690e0a669cf3c62588c3cbc9d5012490cee1c3.tar.bz2
coreclr-ed690e0a669cf3c62588c3cbc9d5012490cee1c3.zip
Clean up some truncation warnings in the JIT.
These changes address casts that trigger warnings C4242, C4254, or C4302 (all of which are truncation-related). Most of the warnings turned out to be innocuous, but there does seem to be some fishiness when truncating pointer values to 32-bit integers for the purpose of generating hash codes.
Diffstat (limited to 'src/jit/valuenum.h')
-rw-r--r--src/jit/valuenum.h26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/jit/valuenum.h b/src/jit/valuenum.h
index 8bd236348a..220af79257 100644
--- a/src/jit/valuenum.h
+++ b/src/jit/valuenum.h
@@ -1215,15 +1215,15 @@ FORCEINLINE T ValueNumStore::SafeGetConstantValue(Chunk* c, unsigned offset)
case TYP_REF:
return CoerceTypRefToT<T>(c, offset);
case TYP_BYREF:
- return (T) reinterpret_cast<VarTypConv<TYP_BYREF>::Type*>(c->m_defs)[offset];
+ return static_cast<T>(reinterpret_cast<VarTypConv<TYP_BYREF>::Type*>(c->m_defs)[offset]);
case TYP_INT:
- return (T) reinterpret_cast<VarTypConv<TYP_INT>::Type*>(c->m_defs)[offset];
+ return static_cast<T>(reinterpret_cast<VarTypConv<TYP_INT>::Type*>(c->m_defs)[offset]);
case TYP_LONG:
- return (T) reinterpret_cast<VarTypConv<TYP_LONG>::Type*>(c->m_defs)[offset];
+ return static_cast<T>(reinterpret_cast<VarTypConv<TYP_LONG>::Type*>(c->m_defs)[offset]);
case TYP_FLOAT:
- return (T) reinterpret_cast<VarTypConv<TYP_FLOAT>::Lang*>(c->m_defs)[offset];
+ return static_cast<T>(reinterpret_cast<VarTypConv<TYP_FLOAT>::Lang*>(c->m_defs)[offset]);
case TYP_DOUBLE:
- return (T) reinterpret_cast<VarTypConv<TYP_DOUBLE>::Lang*>(c->m_defs)[offset];
+ return static_cast<T>(reinterpret_cast<VarTypConv<TYP_DOUBLE>::Lang*>(c->m_defs)[offset]);
default:
assert(false);
return (T)0;
@@ -1251,22 +1251,16 @@ inline bool ValueNumStore::VNFuncIsComparison(VNFunc vnf)
return GenTree::OperIsCompare(gtOp) != 0;
}
-template <typename T>
-inline T ValueNumStore::CoerceTypRefToT(Chunk* c, unsigned offset)
-{
- noway_assert(sizeof(T) >= sizeof(VarTypConv<TYP_REF>::Type));
- return (T) reinterpret_cast<VarTypConv<TYP_REF>::Type*>(c->m_defs)[offset];
-}
-
template <>
-inline float ValueNumStore::CoerceTypRefToT<float>(Chunk* c, unsigned offset)
+inline size_t ValueNumStore::CoerceTypRefToT(Chunk* c, unsigned offset)
{
- unreached();
+ return reinterpret_cast<size_t>(reinterpret_cast<VarTypConv<TYP_REF>::Type*>(c->m_defs)[offset]);
}
-template <>
-inline double ValueNumStore::CoerceTypRefToT<double>(Chunk* c, unsigned offset)
+template <typename T>
+inline T ValueNumStore::CoerceTypRefToT(Chunk* c, unsigned offset)
{
+ noway_assert(sizeof(T) >= sizeof(VarTypConv<TYP_REF>::Type));
unreached();
}