Skip to content

Commit

Permalink
Similar to previous Vec fixes, fix Color4 UB
Browse files Browse the repository at this point in the history
Color4 does not derive from Vec4 the way Color3 derives from Vec3, so UB
fix needed to avoid incorrect optimization in the presence of undefined
behavior.

Signed-off-by: Kimball Thurston <[email protected]>
  • Loading branch information
kdt3rd committed Nov 3, 2024
1 parent cc0d361 commit 854c124
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Imath/ImathColor.h
Original file line number Diff line number Diff line change
Expand Up @@ -513,14 +513,14 @@ template <class T>
IMATH_HOSTDEVICE inline T&
Color4<T>::operator[] (int i) IMATH_NOEXCEPT
{
return (&r)[i];
return reinterpret_cast<T *> (this)[i];
}

template <class T>
IMATH_HOSTDEVICE inline const T&
Color4<T>::operator[] (int i) const IMATH_NOEXCEPT
{
return (&r)[i];
return reinterpret_cast<const T *> (this)[i];
}

template <class T> IMATH_HOSTDEVICE inline Color4<T>::Color4 () IMATH_NOEXCEPT
Expand Down

0 comments on commit 854c124

Please sign in to comment.