From 6138de5f084cafdc98381237c2d8bed7c8804f1c Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 29 Sep 2023 19:10:22 -0400 Subject: Fix for problem with OrderedHashSet causing crash (#3251) * Fix for problem with OrderedHashSet causing crashes during running tests on on g++ 7.3 * Fix typo --- source/core/slang-dictionary.h | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'source/core') diff --git a/source/core/slang-dictionary.h b/source/core/slang-dictionary.h index ff7e201bf..ba4672740 100644 --- a/source/core/slang-dictionary.h +++ b/source/core/slang-dictionary.h @@ -75,6 +75,32 @@ namespace Slang return KeyValuePair(k, v); } + namespace KeyValueDetail { + + template + SLANG_FORCE_INLINE const KEY* getKey(const std::pair* in) + { + return &in->first; + } + template + SLANG_FORCE_INLINE const KEY* getKey(const KeyValuePair* in) + { + return &in->key; + } + + template + SLANG_FORCE_INLINE const VALUE* getValue(const std::pair* in) + { + return &in->second; + } + template + SLANG_FORCE_INLINE const VALUE* getValue(const KeyValuePair* in) + { + return &in->value; + } + + } // namespace KeyValueDetail + const float kMaxLoadFactor = 0.7f; template, typename KeyEqual = std::equal_to> @@ -321,14 +347,13 @@ namespace Slang Iterator() = default; const T& operator*() const { - const auto& [k, v] = *iter; - return k; + return *KeyValueDetail::getKey(std::addressof(*iter)); } const T* operator->() const { - const auto& [k, v] = *iter; - return &k; + return KeyValueDetail::getKey(std::addressof(*iter)); } + Iterator& operator++() { ++iter; -- cgit v1.2.3