Skip to content

Commit 7473eae

Browse files
committed
[cxx-interop] Workaround a compiler crash for CxxStdlib on Windows
This is a workaround for #77856. rdar://140358388
1 parent b13544e commit 7473eae

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

stdlib/public/Cxx/std/String.swift

+12
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,11 @@ extension std.string: Hashable {
198198
@_alwaysEmitIntoClient
199199
public func hash(into hasher: inout Hasher) {
200200
// Call std::hash<std::string>::operator()
201+
#if os(Windows) // FIXME: https://github.com/swiftlang/swift/issues/77856
202+
let cxxHash = __swift_interopHashOfString().callAsFunction(self)
203+
#else
201204
let cxxHash = __swift_interopComputeHashOfString(self)
205+
#endif
202206
hasher.combine(cxxHash)
203207
}
204208
}
@@ -207,7 +211,11 @@ extension std.u16string: Hashable {
207211
@_alwaysEmitIntoClient
208212
public func hash(into hasher: inout Hasher) {
209213
// Call std::hash<std::u16string>::operator()
214+
#if os(Windows) // FIXME: https://github.com/swiftlang/swift/issues/77856
215+
let cxxHash = __swift_interopHashOfU16String().callAsFunction(self)
216+
#else
210217
let cxxHash = __swift_interopComputeHashOfU16String(self)
218+
#endif
211219
hasher.combine(cxxHash)
212220
}
213221
}
@@ -216,7 +224,11 @@ extension std.u32string: Hashable {
216224
@_alwaysEmitIntoClient
217225
public func hash(into hasher: inout Hasher) {
218226
// Call std::hash<std::u32string>::operator()
227+
#if os(Windows) // FIXME: https://github.com/swiftlang/swift/issues/77856
228+
let cxxHash = __swift_interopHashOfU32String().callAsFunction(self)
229+
#else
219230
let cxxHash = __swift_interopComputeHashOfU32String(self)
231+
#endif
220232
hasher.combine(cxxHash)
221233
}
222234
}

0 commit comments

Comments
 (0)