mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-23 10:09:36 +08:00
Merged in vanhoucke/eigen_vanhoucke (pull request PR-118)
Fix two small undefined behaviors caught by static analysis.
This commit is contained in:
commit
84aaef93ba
@ -229,8 +229,10 @@ class CompressedStorage
|
|||||||
internal::scoped_array<Scalar> newValues(size);
|
internal::scoped_array<Scalar> newValues(size);
|
||||||
internal::scoped_array<StorageIndex> newIndices(size);
|
internal::scoped_array<StorageIndex> newIndices(size);
|
||||||
Index copySize = (std::min)(size, m_size);
|
Index copySize = (std::min)(size, m_size);
|
||||||
internal::smart_copy(m_values, m_values+copySize, newValues.ptr());
|
if (copySize>0) {
|
||||||
internal::smart_copy(m_indices, m_indices+copySize, newIndices.ptr());
|
internal::smart_copy(m_values, m_values+copySize, newValues.ptr());
|
||||||
|
internal::smart_copy(m_indices, m_indices+copySize, newIndices.ptr());
|
||||||
|
}
|
||||||
std::swap(m_values,newValues.ptr());
|
std::swap(m_values,newValues.ptr());
|
||||||
std::swap(m_indices,newIndices.ptr());
|
std::swap(m_indices,newIndices.ptr());
|
||||||
m_allocatedSize = size;
|
m_allocatedSize = size;
|
||||||
|
@ -58,7 +58,7 @@ struct TensorIntDivisor {
|
|||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorIntDivisor(const T divider) {
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorIntDivisor(const T divider) {
|
||||||
const int N = 32;
|
const int N = 32;
|
||||||
eigen_assert(divider > 0);
|
eigen_assert(divider > 0);
|
||||||
eigen_assert(divider <= (1<<(N-1)) - 1);
|
eigen_assert(divider <= (1U<<(N-1)) - 1);
|
||||||
|
|
||||||
// fast ln2
|
// fast ln2
|
||||||
const int leading_zeros = count_leading_zeros(divider);
|
const int leading_zeros = count_leading_zeros(divider);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user