[SR-15615] [SE-0263] Incorrect buffer count for small capacity? #57911
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
standard library
Area: Standard library umbrella
Environment
macOS 12.0.1 (21A559)
Xcode version 13.2 (13C90)
Additional Detail from JIRA
md5: 1a2f74d992daac9b9dd8f4d6500c6f1b
Issue Description:
String.init(unsafeUninitializedCapacity:initializingUTF8With:)
has different behavior for a small vs large capacity.The first example is surprising because:
The actual
buffer.count
of 16 exceeds the_SmallString.capacity
of 15.The API documentation suggests the buffer will only have "room for `capacity` UTF-8 code units".
I noticed this issue because I was using
buffer.endIndex
when initializing in reverse.The text was updated successfully, but these errors were encountered: