-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std::vector<std::string> fails to conform to CxxRandomAccessCollection #67410
Comments
over to @egorzhdan |
Btw it works to call a method returning |
I'm facing the same issue, not only with std::string, but even with builtin char/int types: On the C++ side, I do a few aliases: using CharArray = std::vector<char>;
using UCharArray = std::vector<unsigned char>;
using I8Array = std::vector<int8_t>;
using U8Array = std::vector<uint8_t>;
using I16Array = std::vector<int16_t>;
using U16Array = std::vector<uint16_t>;
using I32Array = std::vector<int32_t>;
using U32Array = std::vector<uint32_t>;
using I64Array = std::vector<int64_t>;
using U64Array = std::vector<uint64_t>; On the Swift side, for each of those, a simple function: public static func i8ArrayTest(_ data: I8Array) -> [Int8] {
let ret = Array<Int8>(data)
return ret
} The results are interesting:
Furthermore, if I keep only the two that work (int32_t and uint32_t), I get a link error a bit later, with multiply defined symbols:
I also tried this: #pragma pack(push, 4)
struct FourBytes
{
char x[4];
};
#pragma pack(pop)
using B4Array = std::vector<FourBytes>; Just to see if the issue was with a vector of element of Swift 5.9 / Xcode 15 Beta 4, same issue when compiling from Xcode, or by invoking swiftc directly |
This prevented `std::vector<std::string>` from being auto-conformed to `CxxRandomAccessCollection`. If an iterator type is templated, and does not have an explicit instantiation via a typedef or a using-decl, its specialization will not have an owning Clang module. Make sure we treat it as a part of the Clang module that owns the template decl. rdar://112762768 / resolves #67410
This prevented `std::vector<std::string>` from being auto-conformed to `CxxRandomAccessCollection`. If an iterator type is templated, and does not have an explicit instantiation via a typedef or a using-decl, its specialization will not have an owning Clang module. Make sure we treat it as a part of the Clang module that owns the template decl. rdar://112762768 / resolves #67410 (cherry picked from commit af014c0)
As reported here: https://forums.swift.org/t/c-interop-for-in-loop-requires-std-1-vector-element-to-conform-to-sequence/66232
Reproducer:
https://github.com/Sajjon/CxxRandomAccessCollectionNotWorking
The text was updated successfully, but these errors were encountered: