From f0183dfaac4ef23287e3220b69a16e375d52caab Mon Sep 17 00:00:00 2001 From: Mark Searles Date: Fri, 31 Aug 2018 09:13:43 -0700 Subject: [PATCH] Add keyword 'explicit' to avoid ambiguity Older gcc, e.g., 5.x, see an ambiguity in some calls. Example error output as seen with gcc 5.5: In file included from benchmark_wino.cpp:1: In file included from ./miopen.hpp:13: In file included from /usr/lib/gcc/x86_64-linux-gnu/5.5.0/../../../../include/c++/5.5.0/regex:38: In file included from /usr/lib/gcc/x86_64-linux-gnu/5.5.0/../../../../include/c++/5.5.0/algorithm:62: In file included from /usr/lib/gcc/x86_64-linux-gnu/5.5.0/../../../../include/c++/5.5.0/bits/stl_algo.h:66: In file included from /usr/lib/gcc/x86_64-linux-gnu/5.5.0/../../../../include/c++/5.5.0/random:51: /usr/lib/gcc/x86_64-linux-gnu/5.5.0/../../../../include/c++/5.5.0/bits/random.tcc:1324:27: error: call to 'abs' is ambiguous const double __y = -std::abs(__n) * __param._M_sm - 1; ^~~~~~~~ /opt/rocm/hip/include/hip/hcc_detail/hip_complex.h:345:31: note: candidate function __DEFINE_HIP_COMPLEX_REAL_FUN(abs, hipCabs) --- include/hip/hcc_detail/hip_complex.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/hip/hcc_detail/hip_complex.h b/include/hip/hcc_detail/hip_complex.h index 48a2852a5a..804cc51783 100644 --- a/include/hip/hcc_detail/hip_complex.h +++ b/include/hip/hcc_detail/hip_complex.h @@ -121,7 +121,7 @@ THE SOFTWARE. return ret; \ } #define MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(ComplexT, T) \ - __device__ __host__ ComplexT(T val) : x(val), y(val) {} \ + explicit __device__ __host__ ComplexT(T val) : x(val), y(val) {} \ __device__ __host__ ComplexT(T val1, T val2) : x(val1), y(val2) {} #endif @@ -130,8 +130,8 @@ struct hipFloatComplex { #ifdef __cplusplus public: typedef float value_type; - __device__ __host__ hipFloatComplex() : x(0.0f), y(0.0f) {} - __device__ __host__ hipFloatComplex(float x) : x(x), y(0.0f) {} + explicit __device__ __host__ hipFloatComplex() : x(0.0f), y(0.0f) {} + explicit __device__ __host__ hipFloatComplex(float x) : x(x), y(0.0f) {} __device__ __host__ hipFloatComplex(float x, float y) : x(x), y(y) {} MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipFloatComplex, unsigned short) MAKE_COMPONENT_CONSTRUCTOR_TWO_COMPONENT(hipFloatComplex, signed short)