Skip to content

Commit d795a3b

Browse files
authored
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 <[email protected]>
1 parent 0d9b971 commit d795a3b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/include/OpenImageIO/ustring.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -816,41 +816,41 @@ class OIIO_UTIL_API ustringhash {
816816

817817
/// Construct a ustringhash from a null-terminated C string (char *).
818818
OIIO_DEVICE_CONSTEXPR explicit ustringhash(const char* str)
819-
{
820819
#ifdef __CUDA_ARCH__
821820
// GPU: just compute the hash. This can be constexpr!
822-
m_hash = Strutil::strhash(str);
821+
: m_hash(Strutil::strhash(str))
823822
#else
824823
// CPU: make ustring, get its hash. Note that ustring ctr can't be
825824
// constexpr because it has to modify the internal ustring table.
826-
m_hash = ustring(str).hash();
825+
: m_hash(ustring(str).hash())
827826
#endif
827+
{
828828
}
829829

830830
OIIO_DEVICE_CONSTEXPR explicit ustringhash(const char* str, size_t len)
831-
{
832831
#ifdef __CUDA_ARCH__
833832
// GPU: just compute the hash. This can be constexpr!
834-
m_hash = Strutil::strhash(len, str);
833+
: m_hash(Strutil::strhash(len, str))
835834
#else
836835
// CPU: make ustring, get its hash. Note that ustring ctr can't be
837836
// constexpr because it has to modify the internal ustring table.
838-
m_hash = ustring(str, len).hash();
837+
: m_hash(ustring(str, len).hash())
839838
#endif
839+
{
840840
}
841841

842842
/// Construct a ustringhash from a string_view, which can be
843843
/// auto-converted from either a std::string.
844844
OIIO_DEVICE_CONSTEXPR explicit ustringhash(string_view str)
845-
{
846845
#ifdef __CUDA_ARCH__
847846
// GPU: just compute the hash. This can be constexpr!
848-
m_hash = Strutil::strhash(str);
847+
: m_hash(Strutil::strhash(str))
849848
#else
850849
// CPU: make ustring, get its hash. Note that ustring ctr can't be
851850
// constexpr because it has to modify the internal ustring table.
852-
m_hash = ustring(str).hash();
851+
: m_hash(ustring(str).hash())
853852
#endif
853+
{
854854
}
855855

856856
/// Construct from a raw hash value. Beware: results are undefined if it's

0 commit comments

Comments
 (0)