Skip to content

Commit fb4795d

Browse files
leetcodezvgvassilev
authored andcommitted
Fix bugprone-unhandled-self-assignment in ArrayRef
1 parent 924ee14 commit fb4795d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

include/clad/Differentiator/ArrayRef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ template <typename T> class array_ref {
4848
}
4949

5050
constexpr CUDA_HOST_DEVICE array_ref<T>& operator=(const array_ref<T>& a) {
51+
if (this == &a)
52+
return *this;
5153
assert(m_size == a.size());
5254
for (std::size_t i = 0; i < m_size; ++i)
5355
m_arr[i] = a[i];

0 commit comments

Comments
 (0)