From 7473eae623541f910a51459499f15bfe510a2ae3 Mon Sep 17 00:00:00 2001 From: Egor Zhdan Date: Wed, 27 Nov 2024 16:59:37 +0000 Subject: [PATCH] [cxx-interop] Workaround a compiler crash for CxxStdlib on Windows This is a workaround for https://github.com/swiftlang/swift/issues/77856. rdar://140358388 --- stdlib/public/Cxx/std/String.swift | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/stdlib/public/Cxx/std/String.swift b/stdlib/public/Cxx/std/String.swift index 3d379e81cd17b..1963aa610cebc 100644 --- a/stdlib/public/Cxx/std/String.swift +++ b/stdlib/public/Cxx/std/String.swift @@ -198,7 +198,11 @@ extension std.string: Hashable { @_alwaysEmitIntoClient public func hash(into hasher: inout Hasher) { // Call std::hash::operator() +#if os(Windows) // FIXME: https://github.com/swiftlang/swift/issues/77856 + let cxxHash = __swift_interopHashOfString().callAsFunction(self) +#else let cxxHash = __swift_interopComputeHashOfString(self) +#endif hasher.combine(cxxHash) } } @@ -207,7 +211,11 @@ extension std.u16string: Hashable { @_alwaysEmitIntoClient public func hash(into hasher: inout Hasher) { // Call std::hash::operator() +#if os(Windows) // FIXME: https://github.com/swiftlang/swift/issues/77856 + let cxxHash = __swift_interopHashOfU16String().callAsFunction(self) +#else let cxxHash = __swift_interopComputeHashOfU16String(self) +#endif hasher.combine(cxxHash) } } @@ -216,7 +224,11 @@ extension std.u32string: Hashable { @_alwaysEmitIntoClient public func hash(into hasher: inout Hasher) { // Call std::hash::operator() +#if os(Windows) // FIXME: https://github.com/swiftlang/swift/issues/77856 + let cxxHash = __swift_interopHashOfU32String().callAsFunction(self) +#else let cxxHash = __swift_interopComputeHashOfU32String(self) +#endif hasher.combine(cxxHash) } }