Skip to content

Commit

Permalink
Ensure abs(short) calls abs(int) not abs(double)
Browse files Browse the repository at this point in the history
	* Vc/scalar/math.h: Overload abs(Scalar::Vector<short>) so that
	it can cast to int explicitly. Otherwise older libstdc++ will
	call the abs(double) overload.
  • Loading branch information
mattkretz committed Dec 9, 2020
1 parent 876ff5c commit 37d48ab
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Vc/scalar/math.h
Expand Up @@ -84,13 +84,17 @@ template<typename T> static Vc_ALWAYS_INLINE Scalar::Vector<T> rsqrt(const Scala

template <typename T,
typename = enable_if<std::is_same<T, double>::value || std::is_same<T, float>::value ||
std::is_same<T, short>::value ||
std::is_same<T, int>::value>>
Vc_ALWAYS_INLINE Vc_PURE Scalar::Vector<T> abs(Scalar::Vector<T> x)
{
return std::abs(x.data());
}

Vc_ALWAYS_INLINE Vc_PURE Scalar::Vector<short> abs(Scalar::Vector<short> x)
{
return std::abs(static_cast<int>(x.data()));
}

template<typename T> static Vc_ALWAYS_INLINE void sincos(const Scalar::Vector<T> &x, Scalar::Vector<T> *sin, Scalar::Vector<T> *cos)
{
#if defined(_WIN32) || defined(__APPLE__)
Expand Down

0 comments on commit 37d48ab

Please sign in to comment.