[cxx-interop] std.string created from [CChar] with 16 elements has additional bytes appended to it #81611
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
triage needed
This issue needs more specific labels
Description
Sometimes when a
std.string
is created by passing in[CChar]
tostd.string(_:)
, the created string will have some random bytes appended to it.From what I've seen this occurs when such string is created within a for loop, and only when the array has 16 elements. 15 and 17 element arrays don't seem to produce this behaviour.
Additionally even when the arrays are not the same between iterations, the appended data stays the same.
However, when the code is recompiled in Xcode (because there were changes in code) the issue sometimes does not appear until the code is ran again (or appears in only one of the iterations), while it always happens when using terminal
swift run
(though only from the second iteration onwards)Reproduction
In a swift package executable target that enables Cxx interop:
Expected behavior
A std.string created from an array of 16
CChars
will have only those 16 charctersEnvironment
swift-driver version: 1.120.5 Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
Additional information
No response
The text was updated successfully, but these errors were encountered: