mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Currently without an initializer for the unsafe char pointer type swiftc hits an assert around not being able to handle conversions of unsafe pointers with Any type. This patch adds the ability to convert to a std::string. This is to address issue https://github.com/apple/swift/issues/61218
14 lines
511 B
Swift
14 lines
511 B
Swift
// RUN: %target-swift-frontend -I %S/Inputs -cxx-interoperability-mode=swift-5.9 -emit-ir %s -Xcc -fignore-exceptions | %FileCheck %s
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
import Foundation
|
|
import CxxStdlib
|
|
|
|
// CHECK: @"\01L_selector(UTF8String)"
|
|
// CHECK: @objc_msgSend
|
|
// CHECK: call swiftcc void @"$sSo3stdO3__1O0067basic_stringInt8char_traitsInt8allocatorInt8_FABErpaBGcqaGHerapGgqaV9CxxStdlibEyAFSPys4Int8VGSgcfC"
|
|
|
|
let ObjCStr: NSString = "hello"
|
|
let CxxStr = std.string(ObjCStr.utf8String) // Should not crash here
|