mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-10 23:21:47 +08:00
bug #1356: fix calls to evaluator::coeffRef(0,0) to get the address of the destination
by adding a dstDataPtr() member to the kernel. This fixes undefined behavior if dst is empty (nullptr). (grafted from 0db6d5b3f434ae2e0c2e8b78402e062e67e86339 )
This commit is contained in:
parent
c3597106ab
commit
a4c8701e9a
@ -407,7 +407,7 @@ struct dense_assignment_loop<Kernel, LinearVectorizedTraversal, NoUnrolling>
|
|||||||
: int(Kernel::AssignmentTraits::DstAlignment),
|
: int(Kernel::AssignmentTraits::DstAlignment),
|
||||||
srcAlignment = Kernel::AssignmentTraits::JointAlignment
|
srcAlignment = Kernel::AssignmentTraits::JointAlignment
|
||||||
};
|
};
|
||||||
const Index alignedStart = dstIsAligned ? 0 : internal::first_aligned<requestedAlignment>(&kernel.dstEvaluator().coeffRef(0), size);
|
const Index alignedStart = dstIsAligned ? 0 : internal::first_aligned<requestedAlignment>(kernel.dstDataPtr(), size);
|
||||||
const Index alignedEnd = alignedStart + ((size-alignedStart)/packetSize)*packetSize;
|
const Index alignedEnd = alignedStart + ((size-alignedStart)/packetSize)*packetSize;
|
||||||
|
|
||||||
unaligned_dense_assignment_loop<dstIsAligned!=0>::run(kernel, 0, alignedStart);
|
unaligned_dense_assignment_loop<dstIsAligned!=0>::run(kernel, 0, alignedStart);
|
||||||
@ -527,7 +527,7 @@ struct dense_assignment_loop<Kernel, SliceVectorizedTraversal, NoUnrolling>
|
|||||||
dstAlignment = alignable ? int(requestedAlignment)
|
dstAlignment = alignable ? int(requestedAlignment)
|
||||||
: int(Kernel::AssignmentTraits::DstAlignment)
|
: int(Kernel::AssignmentTraits::DstAlignment)
|
||||||
};
|
};
|
||||||
const Scalar *dst_ptr = &kernel.dstEvaluator().coeffRef(0,0);
|
const Scalar *dst_ptr = kernel.dstDataPtr();
|
||||||
if((!bool(dstIsAligned)) && (UIntPtr(dst_ptr) % sizeof(Scalar))>0)
|
if((!bool(dstIsAligned)) && (UIntPtr(dst_ptr) % sizeof(Scalar))>0)
|
||||||
{
|
{
|
||||||
// the pointer is not aligend-on scalar, so alignment is not possible
|
// the pointer is not aligend-on scalar, so alignment is not possible
|
||||||
@ -683,6 +683,11 @@ public:
|
|||||||
: int(DstEvaluatorType::Flags)&RowMajorBit ? inner
|
: int(DstEvaluatorType::Flags)&RowMajorBit ? inner
|
||||||
: outer;
|
: outer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EIGEN_DEVICE_FUNC const Scalar* dstDataPtr() const
|
||||||
|
{
|
||||||
|
return m_dstExpr.data();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DstEvaluatorType& m_dst;
|
DstEvaluatorType& m_dst;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user