From fbce7d59f44441150235005b70ad0351c7b73378 Mon Sep 17 00:00:00 2001 From: Larry Gritz Date: Fri, 8 Sep 2023 13:40:34 -0700 Subject: [PATCH] fix(ustring): fix Cuda warnings (#3978) To my eyes, these two constructors look like they should be treated as doing exactly the same thing: MyType() : mymember(...) { } and MyType() { mymember = ...; } But nvcc in Cuda mode says no, if the constructor is constexpr, the former is okey dokey, but latter gives a warning. Fine, Cuda, whatver you say. Signed-off-by: Larry Gritz --- src/include/OpenImageIO/ustring.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/include/OpenImageIO/ustring.h b/src/include/OpenImageIO/ustring.h index e9ab95d12e..1f6b3f199c 100644 --- a/src/include/OpenImageIO/ustring.h +++ b/src/include/OpenImageIO/ustring.h @@ -814,41 +814,41 @@ class OIIO_UTIL_API ustringhash { /// Construct a ustringhash from a null-terminated C string (char *). OIIO_DEVICE_CONSTEXPR explicit ustringhash(const char* str) - { #ifdef __CUDA_ARCH__ // GPU: just compute the hash. This can be constexpr! - m_hash = Strutil::strhash(str); + : m_hash(Strutil::strhash(str)) #else // CPU: make ustring, get its hash. Note that ustring ctr can't be // constexpr because it has to modify the internal ustring table. - m_hash = ustring(str).hash(); + : m_hash(ustring(str).hash()) #endif + { } OIIO_DEVICE_CONSTEXPR explicit ustringhash(const char* str, size_t len) - { #ifdef __CUDA_ARCH__ // GPU: just compute the hash. This can be constexpr! - m_hash = Strutil::strhash(len, str); + : m_hash(Strutil::strhash(len, str)) #else // CPU: make ustring, get its hash. Note that ustring ctr can't be // constexpr because it has to modify the internal ustring table. - m_hash = ustring(str, len).hash(); + : m_hash(ustring(str, len).hash()) #endif + { } /// Construct a ustringhash from a string_view, which can be /// auto-converted from either a std::string. OIIO_DEVICE_CONSTEXPR explicit ustringhash(string_view str) - { #ifdef __CUDA_ARCH__ // GPU: just compute the hash. This can be constexpr! - m_hash = Strutil::strhash(str); + : m_hash(Strutil::strhash(str)) #else // CPU: make ustring, get its hash. Note that ustring ctr can't be // constexpr because it has to modify the internal ustring table. - m_hash = ustring(str).hash(); + : m_hash(ustring(str).hash()) #endif + { } /// Construct from a raw hash value. Beware: results are undefined if it's